home *** CD-ROM | disk | FTP | other *** search
MacBinary | 2000-02-25 | 36.8 KB | [TEXT/CWIE] |
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary).
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [CWIE] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 14 57 45 48 69 67 68 | 4c 65 76 65 6c 45 64 69 |..WEHigh|LevelEdi|
|00000010| 74 69 6e 67 2e 63 00 00 | 00 00 00 00 00 00 00 00 |ting.c..|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 43 57 49 | 45 00 00 00 00 00 00 00 |.TEXTCWI|E.......|
|00000050| 00 00 00 00 00 90 d5 00 | 00 01 1e b4 dc 03 20 b4 |........|...... .|
|00000060| dc 03 20 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.. .....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 c2 b6 00 00 |........|........|
|00000080| 2f 2a 0d 20 2a 09 57 45 | 48 69 67 68 4c 65 76 65 |/*. *.WE|HighLeve|
|00000090| 6c 45 64 69 74 69 6e 67 | 2e 63 0d 20 2a 0d 20 2a |lEditing|.c. *. *|
|000000a0| 09 57 41 53 54 45 20 50 | 52 4f 4a 45 43 54 0d 20 |.WASTE P|ROJECT. |
|000000b0| 2a 20 20 48 69 67 68 2d | 4c 65 76 65 6c 20 45 64 |* High-|Level Ed|
|000000c0| 69 74 69 6e 67 20 52 6f | 75 74 69 6e 65 73 0d 20 |iting Ro|utines. |
|000000d0| 2a 0d 20 2a 20 20 43 6f | 70 79 72 69 67 68 74 20 |*. * Co|pyright |
|000000e0| 28 63 29 20 31 39 39 33 | 2d 31 39 39 38 20 4d 61 |(c) 1993|-1998 Ma|
|000000f0| 72 63 6f 20 50 69 6f 76 | 61 6e 65 6c 6c 69 0d 20 |rco Piov|anelli. |
|00000100| 2a 09 41 6c 6c 20 52 69 | 67 68 74 73 20 52 65 73 |*.All Ri|ghts Res|
|00000110| 65 72 76 65 64 0d 20 2a | 0d 20 2a 20 20 43 20 70 |erved. *|. * C p|
|00000120| 6f 72 74 20 62 79 20 44 | 61 6e 20 43 72 65 76 69 |ort by D|an Crevi|
|00000130| 65 72 0d 20 2a 0d 20 2a | 2f 0d 0d 2f 2a 0d 09 50 |er. *. *|/../*..P|
|00000140| 6f 72 74 69 6f 6e 73 20 | 63 6f 70 79 72 69 67 68 |ortions |copyrigh|
|00000150| 74 20 a9 20 31 39 39 38 | 2d 32 30 30 30 20 62 79 |t . 1998|-2000 by|
|00000160| 20 41 70 70 6c 65 20 43 | 6f 6d 70 75 74 65 72 2c | Apple C|omputer,|
|00000170| 20 49 6e 63 2e 20 41 6c | 6c 20 72 69 67 68 74 73 | Inc. Al|l rights|
|00000180| 20 72 65 73 65 72 76 65 | 64 2e 0d 0d 09 43 68 61 | reserve|d....Cha|
|00000190| 6e 67 65 20 48 69 73 74 | 6f 72 79 3a 0d 09 09 30 |nge Hist|ory:...0|
|000001a0| 31 2f 30 37 2f 30 30 09 | 54 57 42 09 09 43 61 72 |1/07/00.|TWB..Car|
|000001b0| 62 6f 6e 3a 20 6e 65 77 | 20 73 63 72 61 70 20 41 |bon: new| scrap A|
|000001c0| 50 49 73 2e 20 0d 09 09 | 31 31 2f 31 31 2f 39 39 |PIs. ...|11/11/99|
|000001d0| 09 54 57 42 09 09 41 64 | 64 20 57 45 53 65 74 4f |.TWB..Ad|d WESetO|
|000001e0| 62 6a 65 63 74 2c 20 77 | 68 69 63 68 20 69 73 20 |bject, w|hich is |
|000001f0| 6c 69 6b 65 20 57 45 49 | 6e 73 65 72 74 4f 62 6a |like WEI|nsertObj|
|00000200| 65 63 74 20 65 78 63 65 | 70 74 20 74 68 65 20 6f |ect exce|pt the o|
|00000210| 62 6a 65 63 74 0d 09 09 | 09 09 09 09 09 69 73 20 |bject...|.....is |
|00000220| 61 64 64 65 64 20 61 73 | 20 61 20 73 74 79 6c 65 |added as| a style|
|00000230| 20 74 6f 20 74 68 65 20 | 65 78 69 73 74 69 6e 67 | to the |existing|
|00000240| 20 74 65 78 74 20 72 61 | 74 68 65 72 20 74 68 61 | text ra|ther tha|
|00000250| 6e 20 72 65 70 6c 61 63 | 69 6e 67 20 69 74 2e 20 |n replac|ing it. |
|00000260| 0d 09 09 31 31 2f 31 30 | 2f 39 39 09 54 57 42 09 |...11/10|/99.TWB.|
|00000270| 09 43 6c 65 61 6e 20 75 | 70 20 74 68 65 20 70 72 |.Clean u|p the pr|
|00000280| 69 76 61 74 65 20 69 6e | 74 65 72 66 61 63 65 73 |ivate in|terfaces|
|00000290| 2e 20 0d 2a 2f 0d 0d 0d | 23 69 6e 63 6c 75 64 65 |. .*/...|#include|
|000002a0| 20 22 57 41 53 54 45 49 | 6e 74 66 2e 68 22 0d 0d | "WASTEI|ntf.h"..|
|000002b0| 70 61 73 63 61 6c 20 76 | 6f 69 64 20 5f 57 45 50 |pascal v|oid _WEP|
|000002c0| 75 73 68 41 63 74 69 6f | 6e 28 57 45 41 63 74 69 |ushActio|n(WEActi|
|000002d0| 6f 6e 48 61 6e 64 6c 65 | 20 68 41 63 74 69 6f 6e |onHandle| hAction|
|000002e0| 29 0d 7b 0d 09 57 45 50 | 74 72 20 70 57 45 20 3d |).{..WEP|tr pWE =|
|000002f0| 20 2a 28 28 2a 68 41 63 | 74 69 6f 6e 29 2d 3e 68 | *((*hAc|tion)->h|
|00000300| 4f 77 6e 65 72 29 3b 0d | 09 57 45 41 63 74 69 6f |Owner);.|.WEActio|
|00000310| 6e 48 61 6e 64 6c 65 20 | 68 4c 61 73 74 3b 0d 0d |nHandle |hLast;..|
|00000320| 09 2f 2f 20 66 69 6e 64 | 20 74 68 65 20 6c 61 73 |.// find| the las|
|00000330| 74 20 61 63 74 69 6f 6e | 20 69 6e 20 74 68 65 20 |t action| in the |
|00000340| 67 69 76 65 6e 20 73 74 | 61 63 6b 0d 09 66 6f 72 |given st|ack..for|
|00000350| 20 28 20 68 4c 61 73 74 | 20 3d 20 68 41 63 74 69 | ( hLast| = hActi|
|00000360| 6f 6e 3b 20 28 2a 68 4c | 61 73 74 29 2d 3e 68 4e |on; (*hL|ast)->hN|
|00000370| 65 78 74 20 21 3d 20 6e | 69 6c 3b 20 68 4c 61 73 |ext != n|il; hLas|
|00000380| 74 20 3d 20 28 2a 68 4c | 61 73 74 29 2d 3e 68 4e |t = (*hL|ast)->hN|
|00000390| 65 78 74 20 29 0d 09 09 | 3b 0d 0d 09 2f 2f 20 70 |ext )...|;...// p|
|000003a0| 72 65 70 65 6e 64 20 68 | 41 63 74 69 6f 6e 20 69 |repend h|Action i|
|000003b0| 6e 20 66 72 6f 6e 74 20 | 6f 66 20 74 68 65 20 61 |n front |of the a|
|000003c0| 63 74 69 6f 6e 20 73 74 | 61 63 6b 0d 09 28 2a 68 |ction st|ack..(*h|
|000003d0| 4c 61 73 74 29 2d 3e 68 | 4e 65 78 74 20 3d 20 70 |Last)->h|Next = p|
|000003e0| 57 45 2d 3e 68 41 63 74 | 69 6f 6e 53 74 61 63 6b |WE->hAct|ionStack|
|000003f0| 3b 0d 09 70 57 45 2d 3e | 68 41 63 74 69 6f 6e 53 |;..pWE->|hActionS|
|00000400| 74 61 63 6b 20 3d 20 68 | 41 63 74 69 6f 6e 3b 0d |tack = h|Action;.|
|00000410| 7d 0d 0d 70 61 73 63 61 | 6c 20 4f 53 45 72 72 20 |}..pasca|l OSErr |
|00000420| 5f 57 45 4e 65 77 41 63 | 74 69 6f 6e 28 53 49 6e |_WENewAc|tion(SIn|
|00000430| 74 33 32 20 72 61 6e 67 | 65 53 74 61 72 74 2c 20 |t32 rang|eStart, |
|00000440| 53 49 6e 74 33 32 20 72 | 61 6e 67 65 45 6e 64 2c |SInt32 r|angeEnd,|
|00000450| 20 53 49 6e 74 33 32 20 | 6e 65 77 54 65 78 74 4c | SInt32 |newTextL|
|00000460| 65 6e 67 74 68 2c 0d 09 | 09 09 09 09 09 09 57 45 |ength,..|......WE|
|00000470| 41 63 74 69 6f 6e 4b 69 | 6e 64 20 61 63 74 69 6f |ActionKi|nd actio|
|00000480| 6e 4b 69 6e 64 2c 20 57 | 45 41 63 74 69 6f 6e 46 |nKind, W|EActionF|
|00000490| 6c 61 67 73 20 61 63 74 | 69 6f 6e 46 6c 61 67 73 |lags act|ionFlags|
|000004a0| 2c 0d 09 09 09 09 09 09 | 09 57 45 48 61 6e 64 6c |,.......|.WEHandl|
|000004b0| 65 20 68 57 45 2c 20 57 | 45 41 63 74 69 6f 6e 48 |e hWE, W|EActionH|
|000004c0| 61 6e 64 6c 65 20 2a 68 | 41 63 74 69 6f 6e 29 0d |andle *h|Action).|
|000004d0| 7b 0d 09 57 45 41 63 74 | 69 6f 6e 20 2a 20 70 41 |{..WEAct|ion * pA|
|000004e0| 63 74 69 6f 6e 20 3d 20 | 6e 69 6c 3b 0d 09 4f 53 |ction = |nil;..OS|
|000004f0| 45 72 72 20 65 72 72 3b | 0d 0d 09 2f 2f 20 61 6c |Err err;|...// al|
|00000500| 6c 6f 63 61 74 65 20 61 | 20 6e 65 77 20 61 63 74 |locate a| new act|
|00000510| 69 6f 6e 20 72 65 63 6f | 72 64 0d 09 69 66 20 28 |ion reco|rd..if (|
|00000520| 28 65 72 72 20 3d 20 5f | 57 45 41 6c 6c 6f 63 61 |(err = _|WEAlloca|
|00000530| 74 65 28 73 69 7a 65 6f | 66 28 57 45 41 63 74 69 |te(sizeo|f(WEActi|
|00000540| 6f 6e 29 2c 20 6b 41 6c | 6c 6f 63 43 6c 65 61 72 |on), kAl|locClear|
|00000550| 2c 20 28 48 61 6e 64 6c | 65 20 2a 29 68 41 63 74 |, (Handl|e *)hAct|
|00000560| 69 6f 6e 29 29 20 21 3d | 20 6e 6f 45 72 72 29 0d |ion)) !=| noErr).|
|00000570| 09 7b 0d 09 09 67 6f 74 | 6f 20 63 6c 65 61 6e 75 |.{...got|o cleanu|
|00000580| 70 3b 0d 09 7d 0d 0d 09 | 2f 2f 20 6c 6f 63 6b 20 |p;..}...|// lock |
|00000590| 69 74 20 64 6f 77 6e 0d | 09 48 4c 6f 63 6b 28 28 |it down.|.HLock((|
|000005a0| 48 61 6e 64 6c 65 29 20 | 2a 68 41 63 74 69 6f 6e |Handle) |*hAction|
|000005b0| 29 3b 0d 09 70 41 63 74 | 69 6f 6e 20 3d 20 2a 2a |);..pAct|ion = **|
|000005c0| 68 41 63 74 69 6f 6e 3b | 0d 0d 09 2f 2f 20 66 69 |hAction;|...// fi|
|000005d0| 6c 6c 20 69 6e 20 74 68 | 65 20 66 69 65 6c 64 73 |ll in th|e fields|
|000005e0| 0d 09 70 41 63 74 69 6f | 6e 2d 3e 68 4f 77 6e 65 |..pActio|n->hOwne|
|000005f0| 72 20 3d 20 68 57 45 3b | 0d 09 70 41 63 74 69 6f |r = hWE;|..pActio|
|00000600| 6e 2d 3e 64 65 6c 52 61 | 6e 67 65 53 74 61 72 74 |n->delRa|ngeStart|
|00000610| 20 3d 20 72 61 6e 67 65 | 53 74 61 72 74 3b 0d 09 | = range|Start;..|
|00000620| 70 41 63 74 69 6f 6e 2d | 3e 64 65 6c 52 61 6e 67 |pAction-|>delRang|
|00000630| 65 4c 65 6e 67 74 68 20 | 3d 20 6e 65 77 54 65 78 |eLength |= newTex|
|00000640| 74 4c 65 6e 67 74 68 3b | 0d 09 70 41 63 74 69 6f |tLength;|..pActio|
|00000650| 6e 2d 3e 69 6e 73 52 61 | 6e 67 65 4c 65 6e 67 74 |n->insRa|ngeLengt|
|00000660| 68 20 3d 20 72 61 6e 67 | 65 45 6e 64 20 2d 20 72 |h = rang|eEnd - r|
|00000670| 61 6e 67 65 53 74 61 72 | 74 3b 0d 09 70 41 63 74 |angeStar|t;..pAct|
|00000680| 69 6f 6e 2d 3e 61 63 74 | 69 6f 6e 4b 69 6e 64 20 |ion->act|ionKind |
|00000690| 3d 20 61 63 74 69 6f 6e | 4b 69 6e 64 3b 0d 09 70 |= action|Kind;..p|
|000006a0| 41 63 74 69 6f 6e 2d 3e | 61 63 74 69 6f 6e 46 6c |Action->|actionFl|
|000006b0| 61 67 73 20 3d 20 61 63 | 74 69 6f 6e 46 6c 61 67 |ags = ac|tionFlag|
|000006c0| 73 3b 0d 0d 09 2f 2f 20 | 72 65 6d 65 6d 62 65 72 |s;...// |remember|
|000006d0| 20 73 65 6c 65 63 74 69 | 6f 6e 20 72 61 6e 67 65 | selecti|on range|
|000006e0| 0d 09 57 45 47 65 74 53 | 65 6c 65 63 74 69 6f 6e |..WEGetS|election|
|000006f0| 28 26 70 41 63 74 69 6f | 6e 2d 3e 68 69 6c 69 74 |(&pActio|n->hilit|
|00000700| 65 53 74 61 72 74 2c 20 | 26 70 41 63 74 69 6f 6e |eStart, |&pAction|
|00000710| 2d 3e 68 69 6c 69 74 65 | 45 6e 64 2c 20 68 57 45 |->hilite|End, hWE|
|00000720| 29 3b 0d 0d 09 2f 2f 20 | 61 6c 6c 6f 63 61 74 65 |);...// |allocate|
|00000730| 20 61 20 68 61 6e 64 6c | 65 20 74 6f 20 68 6f 6c | a handl|e to hol|
|00000740| 64 20 74 68 65 20 74 65 | 78 74 20 74 6f 20 62 65 |d the te|xt to be|
|00000750| 20 73 61 76 65 64 2c 20 | 75 6e 6c 65 73 73 20 6f | saved, |unless o|
|00000760| 74 68 65 72 77 69 73 65 | 20 73 70 65 63 69 66 69 |therwise| specifi|
|00000770| 65 64 0d 09 69 66 20 28 | 28 61 63 74 69 6f 6e 46 |ed..if (|(actionF|
|00000780| 6c 61 67 73 20 26 20 77 | 65 41 46 44 6f 6e 74 53 |lags & w|eAFDontS|
|00000790| 61 76 65 54 65 78 74 29 | 20 3d 3d 20 30 29 0d 09 |aveText)| == 0)..|
|000007a0| 7b 0d 09 09 69 66 20 28 | 28 65 72 72 20 3d 20 5f |{...if (|(err = _|
|000007b0| 57 45 41 6c 6c 6f 63 61 | 74 65 28 30 2c 20 6b 41 |WEAlloca|te(0, kA|
|000007c0| 6c 6c 6f 63 54 65 6d 70 | 2c 20 26 70 41 63 74 69 |llocTemp|, &pActi|
|000007d0| 6f 6e 2d 3e 68 54 65 78 | 74 29 29 20 21 3d 20 6e |on->hTex|t)) != n|
|000007e0| 6f 45 72 72 29 0d 09 09 | 7b 0d 09 09 09 67 6f 74 |oErr)...|{....got|
|000007f0| 6f 20 63 6c 65 61 6e 75 | 70 3b 0d 09 09 7d 0d 09 |o cleanu|p;...}..|
|00000800| 7d 0d 0d 09 2f 2f 20 61 | 6c 6c 6f 63 61 74 65 20 |}...// a|llocate |
|00000810| 61 20 68 61 6e 64 6c 65 | 20 74 6f 20 68 6f 6c 64 |a handle| to hold|
|00000820| 20 74 68 65 20 73 74 79 | 6c 65 73 20 74 6f 20 62 | the sty|les to b|
|00000830| 65 20 73 61 76 65 64 2c | 20 75 6e 6c 65 73 73 20 |e saved,| unless |
|00000840| 6f 74 68 65 72 77 69 73 | 65 20 73 70 65 63 69 66 |otherwis|e specif|
|00000850| 69 65 64 0d 09 69 66 20 | 28 28 61 63 74 69 6f 6e |ied..if |((action|
|00000860| 46 6c 61 67 73 20 26 20 | 77 65 41 46 44 6f 6e 74 |Flags & |weAFDont|
|00000870| 53 61 76 65 53 74 79 6c | 65 73 29 20 3d 3d 20 30 |SaveStyl|es) == 0|
|00000880| 29 0d 09 7b 0d 09 09 69 | 66 20 28 28 65 72 72 20 |)..{...i|f ((err |
|00000890| 3d 20 5f 57 45 41 6c 6c | 6f 63 61 74 65 28 30 2c |= _WEAll|ocate(0,|
|000008a0| 20 6b 41 6c 6c 6f 63 54 | 65 6d 70 2c 20 26 28 48 | kAllocT|emp, &(H|
|000008b0| 61 6e 64 6c 65 29 70 41 | 63 74 69 6f 6e 2d 3e 68 |andle)pA|ction->h|
|000008c0| 53 74 79 6c 65 73 29 29 | 20 21 3d 20 6e 6f 45 72 |Styles))| != noEr|
|000008d0| 72 29 0d 09 09 7b 0d 09 | 09 09 67 6f 74 6f 20 63 |r)...{..|..goto c|
|000008e0| 6c 65 61 6e 75 70 3b 0d | 09 09 7d 0d 09 7d 0d 0d |leanup;.|..}..}..|
|000008f0| 23 69 66 20 57 41 53 54 | 45 5f 4f 42 4a 45 43 54 |#if WAST|E_OBJECT|
|00000900| 53 0d 09 2f 2f 20 61 6c | 6c 6f 63 61 74 65 20 61 |S..// al|locate a|
|00000910| 20 68 61 6e 64 6c 65 20 | 74 6f 20 68 6f 6c 64 20 | handle |to hold |
|00000920| 74 68 65 20 22 73 6f 75 | 70 22 20 74 6f 20 62 65 |the "sou|p" to be|
|00000930| 20 73 61 76 65 64 2c 20 | 75 6e 6c 65 73 73 20 6f | saved, |unless o|
|00000940| 74 68 65 72 77 69 73 65 | 20 73 70 65 63 69 66 69 |therwise| specifi|
|00000950| 65 64 0d 09 69 66 20 28 | 28 61 63 74 69 6f 6e 46 |ed..if (|(actionF|
|00000960| 6c 61 67 73 20 26 20 77 | 65 41 46 44 6f 6e 74 53 |lags & w|eAFDontS|
|00000970| 61 76 65 53 6f 75 70 29 | 20 3d 3d 20 30 29 0d 09 |aveSoup)| == 0)..|
|00000980| 7b 0d 09 09 69 66 20 28 | 28 65 72 72 20 3d 20 5f |{...if (|(err = _|
|00000990| 57 45 41 6c 6c 6f 63 61 | 74 65 28 30 2c 20 6b 41 |WEAlloca|te(0, kA|
|000009a0| 6c 6c 6f 63 54 65 6d 70 | 2c 20 26 70 41 63 74 69 |llocTemp|, &pActi|
|000009b0| 6f 6e 2d 3e 68 53 6f 75 | 70 29 29 20 21 3d 20 6e |on->hSou|p)) != n|
|000009c0| 6f 45 72 72 29 0d 09 09 | 7b 0d 09 09 09 67 6f 74 |oErr)...|{....got|
|000009d0| 6f 20 63 6c 65 61 6e 75 | 70 3b 0d 09 09 7d 0d 09 |o cleanu|p;...}..|
|000009e0| 7d 0d 23 65 6e 64 69 66 | 0d 0d 09 2f 2f 20 6d 61 |}.#endif|...// ma|
|000009f0| 6b 65 20 61 20 63 6f 70 | 79 20 6f 66 20 74 65 78 |ke a cop|y of tex|
|00000a00| 74 20 72 61 6e 67 65 0d | 09 69 66 20 28 28 65 72 |t range.|.if ((er|
|00000a10| 72 20 3d 20 57 45 43 6f | 70 79 52 61 6e 67 65 28 |r = WECo|pyRange(|
|00000a20| 72 61 6e 67 65 53 74 61 | 72 74 2c 20 72 61 6e 67 |rangeSta|rt, rang|
|00000a30| 65 45 6e 64 2c 20 70 41 | 63 74 69 6f 6e 2d 3e 68 |eEnd, pA|ction->h|
|00000a40| 54 65 78 74 2c 20 70 41 | 63 74 69 6f 6e 2d 3e 68 |Text, pA|ction->h|
|00000a50| 53 74 79 6c 65 73 2c 20 | 70 41 63 74 69 6f 6e 2d |Styles, |pAction-|
|00000a60| 3e 68 53 6f 75 70 2c 20 | 68 57 45 29 29 20 21 3d |>hSoup, |hWE)) !=|
|00000a70| 20 6e 6f 45 72 72 29 0d | 09 7b 0d 09 09 67 6f 74 | noErr).|.{...got|
|00000a80| 6f 20 63 6c 65 61 6e 75 | 70 3b 0d 09 7d 0d 0d 09 |o cleanu|p;..}...|
|00000a90| 2f 2f 20 75 6e 6c 6f 63 | 6b 20 61 63 74 69 6f 6e |// unloc|k action|
|00000aa0| 20 72 65 63 6f 72 64 0d | 09 48 55 6e 6c 6f 63 6b | record.|.HUnlock|
|00000ab0| 28 28 48 61 6e 64 6c 65 | 29 20 2a 68 41 63 74 69 |((Handle|) *hActi|
|00000ac0| 6f 6e 29 3b 0d 0d 63 6c | 65 61 6e 75 70 3a 0d 09 |on);..cl|eanup:..|
|00000ad0| 2f 2f 20 63 6c 65 61 6e | 20 75 70 20 69 66 20 61 |// clean| up if a|
|00000ae0| 6e 20 65 72 72 6f 72 20 | 6f 63 63 75 72 72 65 64 |n error |occurred|
|00000af0| 0d 09 69 66 20 28 65 72 | 72 20 21 3d 20 6e 6f 45 |..if (er|r != noE|
|00000b00| 72 72 29 0d 09 7b 0d 09 | 09 69 66 20 28 70 41 63 |rr)..{..|.if (pAc|
|00000b10| 74 69 6f 6e 20 21 3d 20 | 6e 69 6c 29 0d 09 09 7b |tion != |nil)...{|
|00000b20| 0d 09 09 09 5f 57 45 46 | 6f 72 67 65 74 48 61 6e |...._WEF|orgetHan|
|00000b30| 64 6c 65 28 26 70 41 63 | 74 69 6f 6e 2d 3e 68 54 |dle(&pAc|tion->hT|
|00000b40| 65 78 74 29 3b 0d 09 09 | 09 5f 57 45 46 6f 72 67 |ext);...|._WEForg|
|00000b50| 65 74 48 61 6e 64 6c 65 | 28 26 28 48 61 6e 64 6c |etHandle|(&(Handl|
|00000b60| 65 29 70 41 63 74 69 6f | 6e 2d 3e 68 53 74 79 6c |e)pActio|n->hStyl|
|00000b70| 65 73 29 3b 0d 23 69 66 | 20 57 41 53 54 45 5f 4f |es);.#if| WASTE_O|
|00000b80| 42 4a 45 43 54 53 0d 09 | 09 09 5f 57 45 46 6f 72 |BJECTS..|.._WEFor|
|00000b90| 67 65 74 48 61 6e 64 6c | 65 28 26 70 41 63 74 69 |getHandl|e(&pActi|
|00000ba0| 6f 6e 2d 3e 68 53 6f 75 | 70 29 3b 0d 23 65 6e 64 |on->hSou|p);.#end|
|00000bb0| 69 66 0d 09 09 7d 0d 09 | 09 5f 57 45 46 6f 72 67 |if...}..|._WEForg|
|00000bc0| 65 74 48 61 6e 64 6c 65 | 28 28 48 61 6e 64 6c 65 |etHandle|((Handle|
|00000bd0| 20 2a 29 68 41 63 74 69 | 6f 6e 29 3b 0d 09 7d 0d | *)hActi|on);..}.|
|00000be0| 0d 09 2f 2f 20 72 65 74 | 75 72 6e 20 72 65 73 75 |..// ret|urn resu|
|00000bf0| 6c 74 20 63 6f 64 65 0d | 09 72 65 74 75 72 6e 20 |lt code.|.return |
|00000c00| 65 72 72 3b 0d 7d 0d 0d | 70 61 73 63 61 6c 20 76 |err;.}..|pascal v|
|00000c10| 6f 69 64 20 5f 57 45 44 | 69 73 70 6f 73 65 41 63 |oid _WED|isposeAc|
|00000c20| 74 69 6f 6e 28 57 45 41 | 63 74 69 6f 6e 48 61 6e |tion(WEA|ctionHan|
|00000c30| 64 6c 65 20 68 41 63 74 | 69 6f 6e 29 0d 7b 0d 09 |dle hAct|ion).{..|
|00000c40| 57 45 41 63 74 69 6f 6e | 20 2a 70 41 63 74 69 6f |WEAction| *pActio|
|00000c50| 6e 3b 0d 09 57 45 41 63 | 74 69 6f 6e 48 61 6e 64 |n;..WEAc|tionHand|
|00000c60| 6c 65 20 68 4e 65 78 74 | 3b 0d 0d 09 66 6f 72 20 |le hNext|;...for |
|00000c70| 28 20 3b 20 68 41 63 74 | 69 6f 6e 20 21 3d 20 6e |( ; hAct|ion != n|
|00000c80| 69 6c 3b 20 68 41 63 74 | 69 6f 6e 20 3d 20 68 4e |il; hAct|ion = hN|
|00000c90| 65 78 74 20 29 0d 09 7b | 0d 09 09 2f 2f 20 6c 6f |ext )..{|...// lo|
|00000ca0| 63 6b 20 74 68 65 20 61 | 63 74 69 6f 6e 20 72 65 |ck the a|ction re|
|00000cb0| 63 6f 72 64 0d 09 09 48 | 4c 6f 63 6b 28 28 48 61 |cord...H|Lock((Ha|
|00000cc0| 6e 64 6c 65 29 20 68 41 | 63 74 69 6f 6e 29 3b 0d |ndle) hA|ction);.|
|00000cd0| 09 09 70 41 63 74 69 6f | 6e 20 3d 20 2a 68 41 63 |..pActio|n = *hAc|
|00000ce0| 74 69 6f 6e 3b 0d 09 09 | 68 4e 65 78 74 20 3d 20 |tion;...|hNext = |
|00000cf0| 70 41 63 74 69 6f 6e 2d | 3e 68 4e 65 78 74 3b 0d |pAction-|>hNext;.|
|00000d00| 0d 09 09 2f 2f 20 74 68 | 72 6f 77 20 61 77 61 79 |...// th|row away|
|00000d10| 20 74 65 78 74 2c 20 73 | 74 79 6c 65 73 20 61 6e | text, s|tyles an|
|00000d20| 64 20 73 6f 75 70 0d 09 | 09 5f 57 45 46 6f 72 67 |d soup..|._WEForg|
|00000d30| 65 74 48 61 6e 64 6c 65 | 28 26 70 41 63 74 69 6f |etHandle|(&pActio|
|00000d40| 6e 2d 3e 68 54 65 78 74 | 29 3b 0d 09 09 5f 57 45 |n->hText|);..._WE|
|00000d50| 46 6f 72 67 65 74 48 61 | 6e 64 6c 65 28 26 28 48 |ForgetHa|ndle(&(H|
|00000d60| 61 6e 64 6c 65 29 70 41 | 63 74 69 6f 6e 2d 3e 68 |andle)pA|ction->h|
|00000d70| 53 74 79 6c 65 73 29 3b | 0d 23 69 66 20 57 41 53 |Styles);|.#if WAS|
|00000d80| 54 45 5f 4f 42 4a 45 43 | 54 53 0d 09 09 5f 57 45 |TE_OBJEC|TS..._WE|
|00000d90| 46 6f 72 67 65 74 48 61 | 6e 64 6c 65 28 26 70 41 |ForgetHa|ndle(&pA|
|00000da0| 63 74 69 6f 6e 2d 3e 68 | 53 6f 75 70 29 3b 0d 23 |ction->h|Soup);.#|
|00000db0| 65 6e 64 69 66 0d 0d 09 | 09 2f 2f 20 74 68 72 6f |endif...|.// thro|
|00000dc0| 77 20 61 77 61 79 20 74 | 68 65 20 61 63 74 69 6f |w away t|he actio|
|00000dd0| 6e 20 72 65 63 6f 72 64 | 20 69 74 73 65 6c 66 0d |n record| itself.|
|00000de0| 09 09 44 69 73 70 6f 73 | 65 48 61 6e 64 6c 65 28 |..Dispos|eHandle(|
|00000df0| 28 48 61 6e 64 6c 65 29 | 20 68 41 63 74 69 6f 6e |(Handle)| hAction|
|00000e00| 29 3b 0d 09 7d 0d 7d 0d | 0d 70 61 73 63 61 6c 20 |);..}.}.|.pascal |
|00000e10| 76 6f 69 64 20 5f 57 45 | 46 6f 72 67 65 74 41 63 |void _WE|ForgetAc|
|00000e20| 74 69 6f 6e 28 57 45 41 | 63 74 69 6f 6e 48 61 6e |tion(WEA|ctionHan|
|00000e30| 64 6c 65 20 2a 68 41 63 | 74 69 6f 6e 29 0d 7b 0d |dle *hAc|tion).{.|
|00000e40| 09 57 45 41 63 74 69 6f | 6e 48 61 6e 64 6c 65 20 |.WEActio|nHandle |
|00000e50| 74 68 65 41 63 74 69 6f | 6e 3b 0d 0d 09 74 68 65 |theActio|n;...the|
|00000e60| 41 63 74 69 6f 6e 20 3d | 20 2a 68 41 63 74 69 6f |Action =| *hActio|
|00000e70| 6e 3b 0d 09 69 66 20 28 | 74 68 65 41 63 74 69 6f |n;..if (|theActio|
|00000e80| 6e 20 21 3d 20 6e 69 6c | 29 0d 09 7b 0d 09 09 2a |n != nil|)..{...*|
|00000e90| 68 41 63 74 69 6f 6e 20 | 3d 20 6e 69 6c 3b 0d 09 |hAction |= nil;..|
|00000ea0| 09 5f 57 45 44 69 73 70 | 6f 73 65 41 63 74 69 6f |._WEDisp|oseActio|
|00000eb0| 6e 28 74 68 65 41 63 74 | 69 6f 6e 29 3b 0d 09 7d |n(theAct|ion);..}|
|00000ec0| 0d 7d 0d 0d 70 61 73 63 | 61 6c 20 4f 53 45 72 72 |.}..pasc|al OSErr|
|00000ed0| 20 5f 57 45 44 6f 41 63 | 74 69 6f 6e 28 57 45 41 | _WEDoAc|tion(WEA|
|00000ee0| 63 74 69 6f 6e 48 61 6e | 64 6c 65 20 68 41 63 74 |ctionHan|dle hAct|
|00000ef0| 69 6f 6e 29 0d 7b 0d 09 | 57 45 41 63 74 69 6f 6e |ion).{..|WEAction|
|00000f00| 48 61 6e 64 6c 65 20 68 | 52 65 64 6f 41 63 74 69 |Handle h|RedoActi|
|00000f10| 6f 6e 3b 0d 09 57 45 41 | 63 74 69 6f 6e 20 2a 70 |on;..WEA|ction *p|
|00000f20| 41 63 74 69 6f 6e 20 3d | 20 6e 69 6c 3b 0d 09 57 |Action =| nil;..W|
|00000f30| 45 48 61 6e 64 6c 65 20 | 68 57 45 3b 0d 09 57 45 |EHandle |hWE;..WE|
|00000f40| 50 74 72 20 70 57 45 3b | 0d 09 53 49 6e 74 33 32 |Ptr pWE;|..SInt32|
|00000f50| 20 6f 66 66 73 65 74 2c | 20 64 65 6c 4f 66 66 73 | offset,| delOffs|
|00000f60| 65 74 2c 20 69 6e 73 4f | 66 66 73 65 74 3b 0d 09 |et, insO|ffset;..|
|00000f70| 53 49 6e 74 33 32 20 72 | 65 64 72 61 77 53 74 61 |SInt32 r|edrawSta|
|00000f80| 72 74 2c 20 72 65 64 72 | 61 77 45 6e 64 3b 0d 09 |rt, redr|awEnd;..|
|00000f90| 42 6f 6f 6c 65 61 6e 20 | 73 61 76 65 41 63 74 69 |Boolean |saveActi|
|00000fa0| 6f 6e 4c 6f 63 6b 2c 20 | 73 61 76 65 57 45 4c 6f |onLock, |saveWELo|
|00000fb0| 63 6b 2c 20 73 61 76 65 | 54 65 78 74 4c 6f 63 6b |ck, save|TextLock|
|00000fc0| 3b 0d 09 4f 53 45 72 72 | 20 65 72 72 3b 0d 0d 09 |;..OSErr| err;...|
|00000fd0| 2f 2f 20 73 61 6e 69 74 | 79 20 63 68 65 63 6b 3a |// sanit|y check:|
|00000fe0| 20 6d 61 6b 65 20 73 75 | 72 65 20 68 41 63 74 69 | make su|re hActi|
|00000ff0| 6f 6e 20 69 73 6e 27 74 | 20 6e 69 6c 0d 09 69 66 |on isn't| nil..if|
|00001000| 20 28 68 41 63 74 69 6f | 6e 20 3d 3d 20 6e 69 6c | (hActio|n == nil|
|00001010| 29 0d 09 7b 0d 09 09 72 | 65 74 75 72 6e 20 6e 69 |)..{...r|eturn ni|
|00001020| 6c 48 61 6e 64 6c 65 45 | 72 72 3b 0d 09 7d 0d 0d |lHandleE|rr;..}..|
|00001030| 09 2f 2f 20 67 65 74 20 | 68 61 6e 64 6c 65 20 74 |.// get |handle t|
|00001040| 6f 20 61 73 73 6f 63 69 | 61 74 65 64 20 57 45 20 |o associ|ated WE |
|00001050| 69 6e 73 74 61 6e 63 65 | 0d 09 68 57 45 20 3d 20 |instance|..hWE = |
|00001060| 28 2a 68 41 63 74 69 6f | 6e 29 2d 3e 68 4f 77 6e |(*hActio|n)->hOwn|
|00001070| 65 72 3b 0d 0d 09 2f 2f | 20 6c 6f 63 6b 20 74 68 |er;...//| lock th|
|00001080| 65 20 57 45 20 72 65 63 | 6f 72 64 0d 09 73 61 76 |e WE rec|ord..sav|
|00001090| 65 57 45 4c 6f 63 6b 20 | 3d 20 5f 57 45 53 65 74 |eWELock |= _WESet|
|000010a0| 48 61 6e 64 6c 65 4c 6f | 63 6b 28 28 48 61 6e 64 |HandleLo|ck((Hand|
|000010b0| 6c 65 29 20 68 57 45 2c | 20 74 72 75 65 29 3b 0d |le) hWE,| true);.|
|000010c0| 09 70 57 45 20 3d 20 2a | 68 57 45 3b 0d 0d 09 2f |.pWE = *|hWE;.../|
|000010d0| 2f 20 72 65 74 75 72 6e | 20 61 6e 20 65 72 72 6f |/ return| an erro|
|000010e0| 72 20 63 6f 64 65 20 69 | 66 20 74 68 69 73 20 69 |r code i|f this i|
|000010f0| 6e 73 74 61 6e 63 65 20 | 69 73 20 72 65 61 64 2d |nstance |is read-|
|00001100| 6f 6e 6c 79 0d 09 65 72 | 72 20 3d 20 77 65 52 65 |only..er|r = weRe|
|00001110| 61 64 4f 6e 6c 79 45 72 | 72 3b 0d 09 69 66 20 28 |adOnlyEr|r;..if (|
|00001120| 42 54 53 54 28 70 57 45 | 2d 3e 66 65 61 74 75 72 |BTST(pWE|->featur|
|00001130| 65 73 2c 20 77 65 46 52 | 65 61 64 4f 6e 6c 79 29 |es, weFR|eadOnly)|
|00001140| 29 0d 09 7b 0d 09 09 67 | 6f 74 6f 20 63 6c 65 61 |)..{...g|oto clea|
|00001150| 6e 75 70 3b 0d 09 7d 0d | 0d 09 2f 2f 20 73 74 6f |nup;..}.|..// sto|
|00001160| 70 20 61 6e 79 20 6f 6e | 67 6f 69 6e 67 20 69 6e |p any on|going in|
|00001170| 6c 69 6e 65 20 69 6e 70 | 75 74 20 73 65 73 73 69 |line inp|ut sessi|
|00001180| 6f 6e 0d 09 57 45 53 74 | 6f 70 49 6e 6c 69 6e 65 |on..WESt|opInline|
|00001190| 53 65 73 73 69 6f 6e 28 | 68 57 45 29 3b 0d 0d 09 |Session(|hWE);...|
|000011a0| 2f 2f 20 68 69 64 65 20 | 73 65 6c 65 63 74 69 6f |// hide |selectio|
|000011b0| 6e 20 68 69 67 68 6c 69 | 67 68 74 69 6e 67 20 61 |n highli|ghting a|
|000011c0| 6e 64 20 74 68 65 20 63 | 61 72 65 74 0d 09 5f 57 |nd the c|aret.._W|
|000011d0| 45 48 69 6c 69 74 65 52 | 61 6e 67 65 28 70 57 45 |EHiliteR|ange(pWE|
|000011e0| 2d 3e 73 65 6c 53 74 61 | 72 74 2c 20 70 57 45 2d |->selSta|rt, pWE-|
|000011f0| 3e 73 65 6c 45 6e 64 2c | 20 68 57 45 29 3b 0d 09 |>selEnd,| hWE);..|
|00001200| 69 66 20 28 42 54 53 54 | 28 70 57 45 2d 3e 66 6c |if (BTST|(pWE->fl|
|00001210| 61 67 73 2c 20 77 65 46 | 43 61 72 65 74 56 69 73 |ags, weF|CaretVis|
|00001220| 69 62 6c 65 29 29 0d 09 | 7b 0d 09 09 5f 57 45 42 |ible))..|{..._WEB|
|00001230| 6c 69 6e 6b 43 61 72 65 | 74 28 68 57 45 29 3b 0d |linkCare|t(hWE);.|
|00001240| 09 7d 0d 0d 09 72 65 64 | 72 61 77 53 74 61 72 74 |.}...red|rawStart|
|00001250| 20 3d 20 4c 4f 4e 47 5f | 4d 41 58 3b 0d 09 72 65 | = LONG_|MAX;..re|
|00001260| 64 72 61 77 45 6e 64 20 | 3d 20 30 3b 0d 0d 09 66 |drawEnd |= 0;...f|
|00001270| 6f 72 20 28 20 3b 20 68 | 41 63 74 69 6f 6e 20 21 |or ( ; h|Action !|
|00001280| 3d 20 6e 69 6c 3b 20 68 | 41 63 74 69 6f 6e 20 3d |= nil; h|Action =|
|00001290| 20 28 2a 68 41 63 74 69 | 6f 6e 29 2d 3e 68 4e 65 | (*hActi|on)->hNe|
|000012a0| 78 74 20 29 0d 09 7b 0d | 09 09 2f 2f 20 6c 6f 63 |xt )..{.|..// loc|
|000012b0| 6b 20 74 68 65 20 61 63 | 74 69 6f 6e 20 72 65 63 |k the ac|tion rec|
|000012c0| 6f 72 64 0d 09 09 73 61 | 76 65 41 63 74 69 6f 6e |ord...sa|veAction|
|000012d0| 4c 6f 63 6b 20 3d 20 5f | 57 45 53 65 74 48 61 6e |Lock = _|WESetHan|
|000012e0| 64 6c 65 4c 6f 63 6b 28 | 28 48 61 6e 64 6c 65 29 |dleLock(|(Handle)|
|000012f0| 20 68 41 63 74 69 6f 6e | 2c 20 74 72 75 65 29 3b | hAction|, true);|
|00001300| 0d 09 09 70 41 63 74 69 | 6f 6e 20 3d 20 2a 68 41 |...pActi|on = *hA|
|00001310| 63 74 69 6f 6e 3b 0d 09 | 09 6f 66 66 73 65 74 20 |ction;..|.offset |
|00001320| 3d 20 70 41 63 74 69 6f | 6e 2d 3e 64 65 6c 52 61 |= pActio|n->delRa|
|00001330| 6e 67 65 53 74 61 72 74 | 3b 0d 09 09 64 65 6c 4f |ngeStart|;...delO|
|00001340| 66 66 73 65 74 20 3d 20 | 6f 66 66 73 65 74 20 2b |ffset = |offset +|
|00001350| 20 70 41 63 74 69 6f 6e | 2d 3e 64 65 6c 52 61 6e | pAction|->delRan|
|00001360| 67 65 4c 65 6e 67 74 68 | 3b 0d 09 09 69 6e 73 4f |geLength|;...insO|
|00001370| 66 66 73 65 74 20 3d 20 | 6f 66 66 73 65 74 20 2b |ffset = |offset +|
|00001380| 20 70 41 63 74 69 6f 6e | 2d 3e 69 6e 73 52 61 6e | pAction|->insRan|
|00001390| 67 65 4c 65 6e 67 74 68 | 3b 0d 0d 09 09 2f 2f 20 |geLength|;....// |
|000013a0| 75 70 64 61 74 65 20 74 | 68 65 20 6d 6f 64 69 66 |update t|he modif|
|000013b0| 69 63 61 74 69 6f 6e 20 | 63 6f 75 6e 74 20 6f 66 |ication |count of|
|000013c0| 20 74 68 65 20 61 66 66 | 65 63 74 65 64 20 57 45 | the aff|ected WE|
|000013d0| 20 69 6e 73 74 61 6e 63 | 65 0d 09 09 2f 2f 20 6e | instanc|e...// n|
|000013e0| 6f 74 65 20 74 68 61 74 | 20 75 6e 64 6f 69 6e 67 |ote that| undoing|
|000013f0| 20 61 20 63 68 61 6e 67 | 65 20 5f 64 65 63 72 65 | a chang|e _decre|
|00001400| 6d 65 6e 74 73 5f 20 74 | 68 65 20 6d 6f 64 69 66 |ments_ t|he modif|
|00001410| 69 63 61 74 69 6f 6e 20 | 63 6f 75 6e 74 2c 0d 09 |ication |count,..|
|00001420| 09 2f 2f 20 77 68 69 6c | 65 20 72 65 64 6f 69 6e |.// whil|e redoin|
|00001430| 67 20 74 68 65 20 63 68 | 61 6e 67 65 20 69 6e 63 |g the ch|ange inc|
|00001440| 72 65 6d 65 6e 74 73 20 | 69 74 20 61 67 61 69 6e |rements |it again|
|00001450| 0d 09 09 69 66 20 28 70 | 41 63 74 69 6f 6e 2d 3e |...if (p|Action->|
|00001460| 61 63 74 69 6f 6e 46 6c | 61 67 73 20 26 20 77 65 |actionFl|ags & we|
|00001470| 41 46 49 73 52 65 64 6f | 29 0d 09 09 7b 0d 09 09 |AFIsRedo|)...{...|
|00001480| 09 70 57 45 2d 3e 6d 6f | 64 43 6f 75 6e 74 2b 2b |.pWE->mo|dCount++|
|00001490| 3b 0d 09 09 7d 0d 09 09 | 65 6c 73 65 0d 09 09 7b |;...}...|else...{|
|000014a0| 0d 09 09 09 70 57 45 2d | 3e 6d 6f 64 43 6f 75 6e |....pWE-|>modCoun|
|000014b0| 74 2d 2d 3b 0d 09 09 7d | 0d 0d 09 09 2f 2f 20 69 |t--;...}|....// i|
|000014c0| 66 20 75 6e 64 6f 20 73 | 75 70 70 6f 72 74 20 69 |f undo s|upport i|
|000014d0| 73 20 65 6e 61 62 6c 65 | 64 2c 20 73 61 76 65 20 |s enable|d, save |
|000014e0| 74 68 65 20 72 61 6e 67 | 65 20 74 6f 20 62 65 20 |the rang|e to be |
|000014f0| 61 66 66 65 63 74 65 64 | 20 62 79 20 74 68 69 73 |affected| by this|
|00001500| 20 61 63 74 69 6f 6e 0d | 09 09 69 66 20 28 42 54 | action.|..if (BT|
|00001510| 53 54 28 70 57 45 2d 3e | 66 65 61 74 75 72 65 73 |ST(pWE->|features|
|00001520| 2c 20 77 65 46 55 6e 64 | 6f 29 29 0d 09 09 7b 0d |, weFUnd|o))...{.|
|00001530| 09 09 09 69 66 20 28 5f | 57 45 4e 65 77 41 63 74 |...if (_|WENewAct|
|00001540| 69 6f 6e 28 6f 66 66 73 | 65 74 2c 20 64 65 6c 4f |ion(offs|et, delO|
|00001550| 66 66 73 65 74 2c 20 70 | 41 63 74 69 6f 6e 2d 3e |ffset, p|Action->|
|00001560| 69 6e 73 52 61 6e 67 65 | 4c 65 6e 67 74 68 2c 20 |insRange|Length, |
|00001570| 70 41 63 74 69 6f 6e 2d | 3e 61 63 74 69 6f 6e 4b |pAction-|>actionK|
|00001580| 69 6e 64 2c 0d 09 09 09 | 09 28 70 41 63 74 69 6f |ind,....|.(pActio|
|00001590| 6e 2d 3e 61 63 74 69 6f | 6e 46 6c 61 67 73 20 5e |n->actio|nFlags ^|
|000015a0| 20 77 65 41 46 49 73 52 | 65 64 6f 29 2c 20 68 57 | weAFIsR|edo), hW|
|000015b0| 45 2c 20 26 68 52 65 64 | 6f 41 63 74 69 6f 6e 29 |E, &hRed|oAction)|
|000015c0| 20 3d 3d 20 6e 6f 45 72 | 72 29 0d 09 09 09 7b 0d | == noEr|r)....{.|
|000015d0| 09 09 09 09 5f 57 45 50 | 75 73 68 41 63 74 69 6f |...._WEP|ushActio|
|000015e0| 6e 28 68 52 65 64 6f 41 | 63 74 69 6f 6e 29 3b 0d |n(hRedoA|ction);.|
|000015f0| 09 09 09 7d 0d 09 09 7d | 0d 0d 09 09 69 66 20 28 |...}...}|....if (|
|00001600| 70 41 63 74 69 6f 6e 2d | 3e 68 54 65 78 74 20 21 |pAction-|>hText !|
|00001610| 3d 20 6e 69 6c 29 0d 09 | 09 7b 0d 09 09 09 2f 2f |= nil)..|.{....//|
|00001620| 20 64 65 6c 65 74 65 20 | 74 68 65 20 72 61 6e 67 | delete |the rang|
|00001630| 65 20 74 6f 20 72 65 70 | 6c 61 63 65 0d 09 09 09 |e to rep|lace....|
|00001640| 69 66 20 28 28 65 72 72 | 20 3d 20 5f 57 45 44 65 |if ((err| = _WEDe|
|00001650| 6c 65 74 65 52 61 6e 67 | 65 28 6f 66 66 73 65 74 |leteRang|e(offset|
|00001660| 2c 20 64 65 6c 4f 66 66 | 73 65 74 2c 20 68 57 45 |, delOff|set, hWE|
|00001670| 29 29 20 21 3d 20 6e 6f | 45 72 72 29 0d 09 09 09 |)) != no|Err)....|
|00001680| 7b 0d 09 09 09 09 67 6f | 74 6f 20 63 6c 65 61 6e |{.....go|to clean|
|00001690| 75 70 3b 0d 09 09 09 7d | 0d 0d 09 09 09 2f 2f 20 |up;....}|.....// |
|000016a0| 69 6e 73 65 72 74 20 74 | 68 65 20 73 61 76 65 64 |insert t|he saved|
|000016b0| 20 74 65 78 74 0d 09 09 | 09 73 61 76 65 54 65 78 | text...|.saveTex|
|000016c0| 74 4c 6f 63 6b 20 3d 20 | 5f 57 45 53 65 74 48 61 |tLock = |_WESetHa|
|000016d0| 6e 64 6c 65 4c 6f 63 6b | 28 70 41 63 74 69 6f 6e |ndleLock|(pAction|
|000016e0| 2d 3e 68 54 65 78 74 2c | 20 74 72 75 65 29 3b 0d |->hText,| true);.|
|000016f0| 09 09 09 65 72 72 20 3d | 20 5f 57 45 49 6e 73 65 |...err =| _WEInse|
|00001700| 72 74 54 65 78 74 28 6f | 66 66 73 65 74 2c 20 2a |rtText(o|ffset, *|
|00001710| 70 41 63 74 69 6f 6e 2d | 3e 68 54 65 78 74 2c 20 |pAction-|>hText, |
|00001720| 70 41 63 74 69 6f 6e 2d | 3e 69 6e 73 52 61 6e 67 |pAction-|>insRang|
|00001730| 65 4c 65 6e 67 74 68 2c | 20 68 57 45 29 3b 0d 09 |eLength,| hWE);..|
|00001740| 09 09 5f 57 45 53 65 74 | 48 61 6e 64 6c 65 4c 6f |.._WESet|HandleLo|
|00001750| 63 6b 28 70 41 63 74 69 | 6f 6e 2d 3e 68 54 65 78 |ck(pActi|on->hTex|
|00001760| 74 2c 20 73 61 76 65 54 | 65 78 74 4c 6f 63 6b 29 |t, saveT|extLock)|
|00001770| 3b 0d 09 09 09 69 66 20 | 28 65 72 72 20 21 3d 20 |;....if |(err != |
|00001780| 6e 6f 45 72 72 29 0d 09 | 09 09 7b 0d 09 09 09 09 |noErr)..|..{.....|
|00001790| 67 6f 74 6f 20 63 6c 65 | 61 6e 75 70 3b 0d 09 09 |goto cle|anup;...|
|000017a0| 09 7d 0d 09 09 7d 0d 0d | 09 09 2f 2f 20 61 70 70 |.}...}..|..// app|
|000017b0| 6c 79 20 74 68 65 20 73 | 61 76 65 64 20 73 74 79 |ly the s|aved sty|
|000017c0| 6c 65 73 2c 20 69 66 20 | 61 6e 79 0d 09 09 69 66 |les, if |any...if|
|000017d0| 20 28 70 41 63 74 69 6f | 6e 2d 3e 68 53 74 79 6c | (pActio|n->hStyl|
|000017e0| 65 73 20 21 3d 20 6e 69 | 6c 29 0d 09 09 7b 0d 09 |es != ni|l)...{..|
|000017f0| 09 09 69 66 20 28 28 65 | 72 72 20 3d 20 5f 57 45 |..if ((e|rr = _WE|
|00001800| 41 70 70 6c 79 53 74 79 | 6c 65 53 63 72 61 70 28 |ApplySty|leScrap(|
|00001810| 6f 66 66 73 65 74 2c 20 | 69 6e 73 4f 66 66 73 65 |offset, |insOffse|
|00001820| 74 2c 20 70 41 63 74 69 | 6f 6e 2d 3e 68 53 74 79 |t, pActi|on->hSty|
|00001830| 6c 65 73 2c 20 68 57 45 | 29 29 20 21 3d 20 6e 6f |les, hWE|)) != no|
|00001840| 45 72 72 29 0d 09 09 09 | 7b 0d 09 09 09 09 67 6f |Err)....|{.....go|
|00001850| 74 6f 20 63 6c 65 61 6e | 75 70 3b 0d 09 09 09 7d |to clean|up;....}|
|00001860| 0d 09 09 7d 0d 0d 23 69 | 66 20 57 41 53 54 45 5f |...}..#i|f WASTE_|
|00001870| 4f 42 4a 45 43 54 53 0d | 09 09 2f 2f 20 74 68 65 |OBJECTS.|..// the|
|00001880| 20 73 61 6d 65 20 67 6f | 65 73 20 66 6f 72 20 74 | same go|es for t|
|00001890| 68 65 20 73 6f 75 70 0d | 09 09 69 66 20 28 70 41 |he soup.|..if (pA|
|000018a0| 63 74 69 6f 6e 2d 3e 68 | 53 6f 75 70 20 21 3d 20 |ction->h|Soup != |
|000018b0| 6e 69 6c 29 0d 09 09 7b | 0d 09 09 09 69 66 20 28 |nil)...{|....if (|
|000018c0| 28 65 72 72 20 3d 20 5f | 57 45 41 70 70 6c 79 53 |(err = _|WEApplyS|
|000018d0| 6f 75 70 28 6f 66 66 73 | 65 74 2c 20 70 41 63 74 |oup(offs|et, pAct|
|000018e0| 69 6f 6e 2d 3e 68 53 6f | 75 70 2c 20 68 57 45 29 |ion->hSo|up, hWE)|
|000018f0| 29 20 21 3d 20 6e 6f 45 | 72 72 29 0d 09 09 09 7b |) != noE|rr)....{|
|00001900| 0d 09 09 09 09 67 6f 74 | 6f 20 63 6c 65 61 6e 75 |.....got|o cleanu|
|00001910| 70 3b 0d 09 09 09 7d 0d | 09 09 7d 0d 23 65 6e 64 |p;....}.|..}.#end|
|00001920| 69 66 0d 0d 09 09 2f 2f | 20 61 64 6a 75 73 74 20 |if....//| adjust |
|00001930| 72 65 64 72 61 77 20 72 | 61 6e 67 65 20 28 3f 3f |redraw r|ange (??|
|00001940| 3f 20 77 69 6c 6c 20 74 | 68 69 73 20 77 6f 72 6b |? will t|his work|
|00001950| 20 77 69 74 68 20 22 63 | 6f 6d 70 6c 65 78 22 20 | with "c|omplex" |
|00001960| 61 63 74 69 6f 6e 20 73 | 74 61 63 6b 73 20 3f 3f |action s|tacks ??|
|00001970| 3f 29 0d 09 09 69 66 20 | 28 6f 66 66 73 65 74 20 |?)...if |(offset |
|00001980| 3c 20 72 65 64 72 61 77 | 53 74 61 72 74 29 0d 09 |< redraw|Start)..|
|00001990| 09 7b 0d 09 09 09 72 65 | 64 72 61 77 53 74 61 72 |.{....re|drawStar|
|000019a0| 74 20 3d 20 6f 66 66 73 | 65 74 3b 0d 09 09 7d 0d |t = offs|et;...}.|
|000019b0| 09 09 69 66 20 28 69 6e | 73 4f 66 66 73 65 74 20 |..if (in|sOffset |
|000019c0| 3e 20 72 65 64 72 61 77 | 45 6e 64 29 0d 09 09 7b |> redraw|End)...{|
|000019d0| 0d 09 09 09 72 65 64 72 | 61 77 45 6e 64 20 3d 20 |....redr|awEnd = |
|000019e0| 69 6e 73 4f 66 66 73 65 | 74 3b 0d 09 09 7d 0d 0d |insOffse|t;...}..|
|000019f0| 09 09 2f 2f 20 75 6e 6c | 6f 63 6b 20 61 63 74 69 |..// unl|ock acti|
|00001a00| 6f 6e 20 72 65 63 6f 72 | 64 0d 09 09 5f 57 45 53 |on recor|d..._WES|
|00001a10| 65 74 48 61 6e 64 6c 65 | 4c 6f 63 6b 28 28 48 61 |etHandle|Lock((Ha|
|00001a20| 6e 64 6c 65 29 20 68 41 | 63 74 69 6f 6e 2c 20 73 |ndle) hA|ction, s|
|00001a30| 61 76 65 41 63 74 69 6f | 6e 4c 6f 63 6b 29 3b 0d |aveActio|nLock);.|
|00001a40| 0d 09 7d 20 2f 2f 20 66 | 6f 72 0d 0d 09 2f 2f 20 |..} // f|or...// |
|00001a50| 72 65 73 74 6f 72 65 20 | 74 68 65 20 6f 72 69 67 |restore |the orig|
|00001a60| 69 6e 61 6c 20 73 65 6c | 65 63 74 69 6f 6e 20 72 |inal sel|ection r|
|00001a70| 61 6e 67 65 0d 09 70 57 | 45 2d 3e 73 65 6c 53 74 |ange..pW|E->selSt|
|00001a80| 61 72 74 20 3d 20 70 41 | 63 74 69 6f 6e 2d 3e 68 |art = pA|ction->h|
|00001a90| 69 6c 69 74 65 53 74 61 | 72 74 3b 0d 09 70 57 45 |iliteSta|rt;..pWE|
|00001aa0| 2d 3e 73 65 6c 45 6e 64 | 20 3d 20 70 41 63 74 69 |->selEnd| = pActi|
|00001ab0| 6f 6e 2d 3e 68 69 6c 69 | 74 65 45 6e 64 3b 0d 0d |on->hili|teEnd;..|
|00001ac0| 09 2f 2f 20 72 65 64 72 | 61 77 20 74 68 65 20 74 |.// redr|aw the t|
|00001ad0| 65 78 74 0d 09 69 66 20 | 28 28 65 72 72 20 3d 20 |ext..if |((err = |
|00001ae0| 5f 57 45 52 65 64 72 61 | 77 28 72 65 64 72 61 77 |_WERedra|w(redraw|
|00001af0| 53 74 61 72 74 2c 20 72 | 65 64 72 61 77 45 6e 64 |Start, r|edrawEnd|
|00001b00| 2c 20 68 57 45 29 29 20 | 21 3d 20 6e 6f 45 72 72 |, hWE)) |!= noErr|
|00001b10| 29 0d 09 7b 0d 09 09 67 | 6f 74 6f 20 63 6c 65 61 |)..{...g|oto clea|
|00001b20| 6e 75 70 3b 0d 09 7d 0d | 0d 09 2f 2f 20 63 6c 65 |nup;..}.|..// cle|
|00001b30| 61 72 20 72 65 73 75 6c | 74 20 63 6f 64 65 0d 09 |ar resul|t code..|
|00001b40| 65 72 72 20 3d 20 6e 6f | 45 72 72 3b 0d 0d 63 6c |err = no|Err;..cl|
|00001b50| 65 61 6e 75 70 3a 0d 09 | 2f 2f 20 75 6e 6c 6f 63 |eanup:..|// unloc|
|00001b60| 6b 20 74 68 65 20 57 45 | 20 72 65 63 6f 72 64 0d |k the WE| record.|
|00001b70| 09 5f 57 45 53 65 74 48 | 61 6e 64 6c 65 4c 6f 63 |._WESetH|andleLoc|
|00001b80| 6b 28 28 48 61 6e 64 6c | 65 29 20 68 57 45 2c 20 |k((Handl|e) hWE, |
|00001b90| 73 61 76 65 57 45 4c 6f | 63 6b 29 3b 0d 0d 09 2f |saveWELo|ck);.../|
|00001ba0| 2f 20 72 65 74 75 72 6e | 20 72 65 73 75 6c 74 20 |/ return| result |
|00001bb0| 63 6f 64 65 0d 09 72 65 | 74 75 72 6e 20 65 72 72 |code..re|turn err|
|00001bc0| 3b 0d 7d 0d 0d 70 61 73 | 63 61 6c 20 4f 53 45 72 |;.}..pas|cal OSEr|
|00001bd0| 72 20 57 45 55 6e 64 6f | 28 57 45 48 61 6e 64 6c |r WEUndo|(WEHandl|
|00001be0| 65 20 68 57 45 29 0d 7b | 0d 09 57 45 50 74 72 20 |e hWE).{|..WEPtr |
|00001bf0| 70 57 45 3b 0d 09 57 45 | 41 63 74 69 6f 6e 48 61 |pWE;..WE|ActionHa|
|00001c00| 6e 64 6c 65 20 68 41 63 | 74 69 6f 6e 3b 0d 09 42 |ndle hAc|tion;..B|
|00001c10| 6f 6f 6c 65 61 6e 20 73 | 61 76 65 57 45 4c 6f 63 |oolean s|aveWELoc|
|00001c20| 6b 3b 0d 09 4f 53 45 72 | 72 20 65 72 72 3b 0d 0d |k;..OSEr|r err;..|
|00001c30| 09 2f 2f 20 6c 6f 63 6b | 20 74 68 65 20 57 45 20 |.// lock| the WE |
|00001c40| 72 65 63 6f 72 64 0d 09 | 73 61 76 65 57 45 4c 6f |record..|saveWELo|
|00001c50| 63 6b 20 3d 20 5f 57 45 | 53 65 74 48 61 6e 64 6c |ck = _WE|SetHandl|
|00001c60| 65 4c 6f 63 6b 28 28 48 | 61 6e 64 6c 65 29 20 68 |eLock((H|andle) h|
|00001c70| 57 45 2c 20 74 72 75 65 | 29 3b 0d 09 70 57 45 20 |WE, true|);..pWE |
|00001c80| 3d 20 2a 68 57 45 3b 0d | 0d 09 2f 2f 20 22 64 65 |= *hWE;.|..// "de|
|00001c90| 74 61 63 68 22 20 74 68 | 65 20 61 63 74 69 6f 6e |tach" th|e action|
|00001ca0| 20 73 74 61 63 6b 20 66 | 72 6f 6d 20 74 68 65 20 | stack f|rom the |
|00001cb0| 57 45 20 69 6e 73 74 61 | 6e 63 65 0d 09 68 41 63 |WE insta|nce..hAc|
|00001cc0| 74 69 6f 6e 20 3d 20 70 | 57 45 2d 3e 68 41 63 74 |tion = p|WE->hAct|
|00001cd0| 69 6f 6e 53 74 61 63 6b | 3b 0d 09 70 57 45 2d 3e |ionStack|;..pWE->|
|00001ce0| 68 41 63 74 69 6f 6e 53 | 74 61 63 6b 20 3d 20 6e |hActionS|tack = n|
|00001cf0| 69 6c 3b 0d 0d 09 69 66 | 20 28 68 41 63 74 69 6f |il;...if| (hActio|
|00001d00| 6e 20 21 3d 20 6e 69 6c | 29 0d 09 7b 0d 09 09 2f |n != nil|)..{.../|
|00001d10| 2f 20 70 65 72 66 6f 72 | 6d 20 74 68 65 20 61 63 |/ perfor|m the ac|
|00001d20| 74 69 6f 6e 2e 2e 2e 0d | 09 09 65 72 72 20 3d 20 |tion....|..err = |
|00001d30| 5f 57 45 44 6f 41 63 74 | 69 6f 6e 28 68 41 63 74 |_WEDoAct|ion(hAct|
|00001d40| 69 6f 6e 29 3b 0d 0d 09 | 09 2f 2f 20 2e 2e 2e 61 |ion);...|.// ...a|
|00001d50| 6e 64 20 74 68 72 6f 77 | 20 69 74 20 61 77 61 79 |nd throw| it away|
|00001d60| 0d 09 09 5f 57 45 44 69 | 73 70 6f 73 65 41 63 74 |..._WEDi|sposeAct|
|00001d70| 69 6f 6e 28 68 41 63 74 | 69 6f 6e 29 3b 0d 09 7d |ion(hAct|ion);..}|
|00001d80| 0d 09 65 6c 73 65 0d 09 | 7b 0d 09 09 2f 2f 20 72 |..else..|{...// r|
|00001d90| 65 74 75 72 6e 20 61 6e | 20 65 72 72 6f 72 20 63 |eturn an| error c|
|00001da0| 6f 64 65 20 69 66 20 74 | 68 65 20 75 6e 64 6f 20 |ode if t|he undo |
|00001db0| 62 75 66 66 65 72 20 69 | 73 20 65 6d 70 74 79 0d |buffer i|s empty.|
|00001dc0| 09 09 65 72 72 20 3d 20 | 77 65 43 61 6e 74 55 6e |..err = |weCantUn|
|00001dd0| 64 6f 45 72 72 3b 0d 09 | 7d 0d 0d 09 2f 2f 20 75 |doErr;..|}...// u|
|00001de0| 6e 6c 6f 63 6b 20 74 68 | 65 20 57 45 20 72 65 63 |nlock th|e WE rec|
|00001df0| 6f 72 64 0d 09 5f 57 45 | 53 65 74 48 61 6e 64 6c |ord.._WE|SetHandl|
|00001e00| 65 4c 6f 63 6b 28 28 48 | 61 6e 64 6c 65 29 20 68 |eLock((H|andle) h|
|00001e10| 57 45 2c 20 73 61 76 65 | 57 45 4c 6f 63 6b 29 3b |WE, save|WELock);|
|00001e20| 0d 0d 09 72 65 74 75 72 | 6e 20 65 72 72 3b 0d 7d |...retur|n err;.}|
|00001e30| 0d 0d 70 61 73 63 61 6c | 20 76 6f 69 64 20 57 45 |..pascal| void WE|
|00001e40| 43 6c 65 61 72 55 6e 64 | 6f 28 57 45 48 61 6e 64 |ClearUnd|o(WEHand|
|00001e50| 6c 65 20 68 57 45 29 0d | 7b 0d 09 57 45 50 74 72 |le hWE).|{..WEPtr|
|00001e60| 20 70 57 45 20 3d 20 2a | 68 57 45 3b 0d 0d 09 2f | pWE = *|hWE;.../|
|00001e70| 2f 20 64 69 73 70 6f 73 | 65 20 6f 66 20 74 68 65 |/ dispos|e of the|
|00001e80| 20 61 63 74 69 6f 6e 20 | 63 68 61 69 6e 20 61 73 | action |chain as|
|00001e90| 73 6f 63 69 61 74 65 64 | 20 77 69 74 68 20 74 68 |sociated| with th|
|00001ea0| 65 20 67 69 76 65 6e 20 | 57 45 20 69 6e 73 74 61 |e given |WE insta|
|00001eb0| 6e 63 65 2c 0d 09 2f 2f | 20 75 6e 6c 65 73 73 20 |nce,..//| unless |
|00001ec0| 77 65 46 41 63 63 75 6d | 75 6c 61 74 65 55 6e 64 |weFAccum|ulateUnd|
|00001ed0| 6f 73 20 69 73 20 73 65 | 74 0d 09 69 66 20 28 21 |os is se|t..if (!|
|00001ee0| 20 42 54 53 54 28 70 57 | 45 2d 3e 66 6c 61 67 73 | BTST(pW|E->flags|
|00001ef0| 2c 20 77 65 46 41 63 63 | 75 6d 75 6c 61 74 65 55 |, weFAcc|umulateU|
|00001f00| 6e 64 6f 73 29 29 0d 09 | 7b 0d 09 09 5f 57 45 46 |ndos))..|{..._WEF|
|00001f10| 6f 72 67 65 74 41 63 74 | 69 6f 6e 28 26 70 57 45 |orgetAct|ion(&pWE|
|00001f20| 2d 3e 68 41 63 74 69 6f | 6e 53 74 61 63 6b 29 3b |->hActio|nStack);|
|00001f30| 0d 09 7d 0d 7d 0d 0d 70 | 61 73 63 61 6c 20 57 45 |..}.}..p|ascal WE|
|00001f40| 41 63 74 69 6f 6e 4b 69 | 6e 64 20 57 45 47 65 74 |ActionKi|nd WEGet|
|00001f50| 55 6e 64 6f 49 6e 66 6f | 28 42 6f 6f 6c 65 61 6e |UndoInfo|(Boolean|
|00001f60| 20 2a 72 65 64 6f 46 6c | 61 67 2c 20 57 45 48 61 | *redoFl|ag, WEHa|
|00001f70| 6e 64 6c 65 20 68 57 45 | 29 0d 7b 0d 09 57 45 41 |ndle hWE|).{..WEA|
|00001f80| 63 74 69 6f 6e 48 61 6e | 64 6c 65 20 68 41 63 74 |ctionHan|dle hAct|
|00001f90| 69 6f 6e 3b 0d 09 57 45 | 41 63 74 69 6f 6e 4b 69 |ion;..WE|ActionKi|
|00001fa0| 6e 64 20 74 68 65 4b 69 | 6e 64 20 3d 20 77 65 41 |nd theKi|nd = weA|
|00001fb0| 4b 4e 6f 6e 65 3b 0d 09 | 42 6f 6f 6c 65 61 6e 20 |KNone;..|Boolean |
|00001fc0| 74 68 65 46 6c 61 67 20 | 3d 20 66 61 6c 73 65 3b |theFlag |= false;|
|00001fd0| 0d 0d 09 69 66 20 28 28 | 68 41 63 74 69 6f 6e 20 |...if ((|hAction |
|00001fe0| 3d 20 28 2a 68 57 45 29 | 2d 3e 68 41 63 74 69 6f |= (*hWE)|->hActio|
|00001ff0| 6e 53 74 61 63 6b 29 20 | 21 3d 20 6e 69 6c 29 0d |nStack) |!= nil).|
|00002000| 09 7b 0d 09 09 74 68 65 | 4b 69 6e 64 20 3d 20 28 |.{...the|Kind = (|
|00002010| 2a 68 41 63 74 69 6f 6e | 29 2d 3e 61 63 74 69 6f |*hAction|)->actio|
|00002020| 6e 4b 69 6e 64 3b 0d 09 | 09 74 68 65 46 6c 61 67 |nKind;..|.theFlag|
|00002030| 20 3d 20 28 28 28 2a 68 | 41 63 74 69 6f 6e 29 2d | = (((*h|Action)-|
|00002040| 3e 61 63 74 69 6f 6e 46 | 6c 61 67 73 20 26 20 77 |>actionF|lags & w|
|00002050| 65 41 46 49 73 52 65 64 | 6f 29 20 21 3d 20 30 29 |eAFIsRed|o) != 0)|
|00002060| 3b 0d 09 7d 0d 0d 09 69 | 66 20 28 72 65 64 6f 46 |;..}...i|f (redoF|
|00002070| 6c 61 67 20 21 3d 20 6e | 69 6c 29 0d 09 7b 0d 09 |lag != n|il)..{..|
|00002080| 09 2a 72 65 64 6f 46 6c | 61 67 20 3d 20 74 68 65 |.*redoFl|ag = the|
|00002090| 46 6c 61 67 3b 0d 09 7d | 0d 09 72 65 74 75 72 6e |Flag;..}|..return|
|000020a0| 20 74 68 65 4b 69 6e 64 | 3b 0d 7d 0d 0d 70 61 73 | theKind|;.}..pas|
|000020b0| 63 61 6c 20 4f 53 45 72 | 72 20 57 45 42 65 67 69 |cal OSEr|r WEBegi|
|000020c0| 6e 41 63 74 69 6f 6e 28 | 57 45 48 61 6e 64 6c 65 |nAction(|WEHandle|
|000020d0| 20 68 57 45 29 0d 7b 0d | 09 57 45 50 74 72 20 70 | hWE).{.|.WEPtr p|
|000020e0| 57 45 20 3d 20 2a 68 57 | 45 3b 0d 0d 09 69 66 20 |WE = *hW|E;...if |
|000020f0| 28 42 54 53 54 28 70 57 | 45 2d 3e 66 6c 61 67 73 |(BTST(pW|E->flags|
|00002100| 2c 20 77 65 46 41 63 63 | 75 6d 75 6c 61 74 65 55 |, weFAcc|umulateU|
|00002110| 6e 64 6f 73 29 29 0d 09 | 7b 0d 09 09 2f 2f 09 63 |ndos))..|{...//.c|
|00002120| 61 6c 6c 69 6e 67 20 57 | 45 42 65 67 69 6e 41 63 |alling W|EBeginAc|
|00002130| 74 69 6f 6e 20 74 77 69 | 63 65 20 69 6e 20 61 20 |tion twi|ce in a |
|00002140| 72 6f 77 0d 09 09 2f 2f | 09 69 73 20 63 6f 6e 73 |row...//|.is cons|
|00002150| 69 64 65 72 65 64 20 61 | 20 70 72 6f 74 6f 63 6f |idered a| protoco|
|00002160| 6c 20 65 72 72 6f 72 0d | 09 09 72 65 74 75 72 6e |l error.|..return|
|00002170| 20 77 65 50 72 6f 74 6f | 63 6f 6c 45 72 72 3b 0d | weProto|colErr;.|
|00002180| 09 7d 0d 0d 09 2f 2f 09 | 73 65 74 20 77 65 46 41 |.}...//.|set weFA|
|00002190| 63 63 75 6d 75 6c 61 74 | 65 55 6e 64 6f 73 20 73 |ccumulat|eUndos s|
|000021a0| 6f 20 74 68 61 74 20 65 | 61 63 68 20 6e 65 77 20 |o that e|ach new |
|000021b0| 63 68 61 6e 67 65 20 77 | 69 6c 6c 20 61 64 64 20 |change w|ill add |
|000021c0| 74 6f 2c 0d 09 2f 2f 09 | 72 61 74 68 65 72 20 74 |to,..//.|rather t|
|000021d0| 68 61 6e 20 72 65 70 6c | 61 63 65 2c 20 74 68 65 |han repl|ace, the|
|000021e0| 20 65 78 69 73 74 69 6e | 67 20 61 63 74 69 6f 6e | existin|g action|
|000021f0| 20 73 74 61 63 6b 0d 09 | 42 53 45 54 28 70 57 45 | stack..|BSET(pWE|
|00002200| 2d 3e 66 6c 61 67 73 2c | 20 77 65 46 41 63 63 75 |->flags,| weFAccu|
|00002210| 6d 75 6c 61 74 65 55 6e | 64 6f 73 29 3b 0d 0d 09 |mulateUn|dos);...|
|00002220| 2f 2f 09 73 74 61 72 74 | 20 77 69 74 68 20 61 20 |//.start| with a |
|00002230| 66 72 65 73 68 20 61 63 | 74 69 6f 6e 20 73 74 61 |fresh ac|tion sta|
|00002240| 63 6b 0d 09 5f 57 45 46 | 6f 72 67 65 74 41 63 74 |ck.._WEF|orgetAct|
|00002250| 69 6f 6e 28 26 70 57 45 | 2d 3e 68 41 63 74 69 6f |ion(&pWE|->hActio|
|00002260| 6e 53 74 61 63 6b 29 3b | 0d 0d 09 72 65 74 75 72 |nStack);|...retur|
|00002270| 6e 20 6e 6f 45 72 72 3b | 0d 7d 0d 0d 70 61 73 63 |n noErr;|.}..pasc|
|00002280| 61 6c 20 4f 53 45 72 72 | 20 57 45 45 6e 64 41 63 |al OSErr| WEEndAc|
|00002290| 74 69 6f 6e 28 57 45 41 | 63 74 69 6f 6e 4b 69 6e |tion(WEA|ctionKin|
|000022a0| 64 20 61 63 74 69 6f 6e | 4b 69 6e 64 2c 20 57 45 |d action|Kind, WE|
|000022b0| 48 61 6e 64 6c 65 20 68 | 57 45 29 0d 7b 0d 09 57 |Handle h|WE).{..W|
|000022c0| 45 50 74 72 20 70 57 45 | 20 3d 20 2a 68 57 45 3b |EPtr pWE| = *hWE;|
|000022d0| 0d 0d 09 69 66 20 28 21 | 20 42 54 53 54 28 70 57 |...if (!| BTST(pW|
|000022e0| 45 2d 3e 66 6c 61 67 73 | 2c 20 77 65 46 41 63 63 |E->flags|, weFAcc|
|000022f0| 75 6d 75 6c 61 74 65 55 | 6e 64 6f 73 29 29 0d 09 |umulateU|ndos))..|
|00002300| 7b 0d 09 09 2f 2f 09 61 | 20 63 61 6c 6c 20 74 6f |{...//.a| call to|
|00002310| 20 57 45 45 6e 64 41 63 | 74 69 6f 6e 20 6e 6f 74 | WEEndAc|tion not|
|00002320| 20 62 61 6c 61 6e 63 65 | 64 20 62 79 20 61 20 70 | balance|d by a p|
|00002330| 72 65 76 69 6f 75 73 0d | 09 09 2f 2f 09 63 61 6c |revious.|..//.cal|
|00002340| 6c 20 74 6f 20 57 45 42 | 65 67 69 6e 41 63 74 69 |l to WEB|eginActi|
|00002350| 6f 6e 20 69 73 20 61 20 | 70 72 6f 74 6f 63 6f 6c |on is a |protocol|
|00002360| 20 65 72 72 6f 72 0d 09 | 09 72 65 74 75 72 6e 20 | error..|.return |
|00002370| 77 65 50 72 6f 74 6f 63 | 6f 6c 45 72 72 3b 0d 09 |weProtoc|olErr;..|
|00002380| 7d 0d 0d 09 2f 2f 09 73 | 74 6f 70 20 61 63 63 75 |}...//.s|top accu|
|00002390| 6d 75 6c 61 74 69 6e 67 | 20 61 63 74 69 6f 6e 73 |mulating| actions|
|000023a0| 0d 09 42 43 4c 52 28 70 | 57 45 2d 3e 66 6c 61 67 |..BCLR(p|WE->flag|
|000023b0| 73 2c 20 77 65 46 41 63 | 63 75 6d 75 6c 61 74 65 |s, weFAc|cumulate|
|000023c0| 55 6e 64 6f 73 29 3b 0d | 0d 09 2f 2f 09 6d 61 6b |Undos);.|..//.mak|
|000023d0| 65 20 73 75 72 65 20 77 | 65 20 68 61 76 65 20 61 |e sure w|e have a|
|000023e0| 20 6e 6f 6e 2d 65 6d 70 | 74 79 20 61 63 74 69 6f | non-emp|ty actio|
|000023f0| 6e 20 73 74 61 63 6b 0d | 09 69 66 20 28 70 57 45 |n stack.|.if (pWE|
|00002400| 2d 3e 68 41 63 74 69 6f | 6e 53 74 61 63 6b 20 3d |->hActio|nStack =|
|00002410| 3d 20 6e 69 6c 29 0d 09 | 7b 0d 09 09 72 65 74 75 |= nil)..|{...retu|
|00002420| 72 6e 20 77 65 43 61 6e | 74 55 6e 64 6f 45 72 72 |rn weCan|tUndoErr|
|00002430| 3b 0d 09 7d 0d 0d 09 2f | 2f 09 73 65 74 20 74 68 |;..}.../|/.set th|
|00002440| 65 20 61 63 74 69 6f 6e | 20 6b 69 6e 64 0d 09 28 |e action| kind..(|
|00002450| 2a 70 57 45 2d 3e 68 41 | 63 74 69 6f 6e 53 74 61 |*pWE->hA|ctionSta|
|00002460| 63 6b 29 2d 3e 61 63 74 | 69 6f 6e 4b 69 6e 64 20 |ck)->act|ionKind |
|00002470| 3d 20 61 63 74 69 6f 6e | 4b 69 6e 64 3b 0d 0d 09 |= action|Kind;...|
|00002480| 72 65 74 75 72 6e 20 6e | 6f 45 72 72 3b 0d 7d 0d |return n|oErr;.}.|
|00002490| 0d 70 61 73 63 61 6c 20 | 55 49 6e 74 33 32 20 57 |.pascal |UInt32 W|
|000024a0| 45 47 65 74 4d 6f 64 43 | 6f 75 6e 74 28 57 45 48 |EGetModC|ount(WEH|
|000024b0| 61 6e 64 6c 65 20 68 57 | 45 29 0d 7b 0d 09 72 65 |andle hW|E).{..re|
|000024c0| 74 75 72 6e 20 28 2a 68 | 57 45 29 2d 3e 6d 6f 64 |turn (*h|WE)->mod|
|000024d0| 43 6f 75 6e 74 3b 0d 7d | 0d 0d 70 61 73 63 61 6c |Count;.}|..pascal|
|000024e0| 20 76 6f 69 64 20 57 45 | 52 65 73 65 74 4d 6f 64 | void WE|ResetMod|
|000024f0| 43 6f 75 6e 74 28 57 45 | 48 61 6e 64 6c 65 20 68 |Count(WE|Handle h|
|00002500| 57 45 29 0d 7b 0d 09 28 | 2a 68 57 45 29 2d 3e 6d |WE).{..(|*hWE)->m|
|00002510| 6f 64 43 6f 75 6e 74 20 | 3d 20 30 3b 0d 09 5f 57 |odCount |= 0;.._W|
|00002520| 45 46 6f 72 67 65 74 41 | 63 74 69 6f 6e 28 26 28 |EForgetA|ction(&(|
|00002530| 2a 68 57 45 29 2d 3e 68 | 41 63 74 69 6f 6e 53 74 |*hWE)->h|ActionSt|
|00002540| 61 63 6b 29 3b 0d 7d 0d | 0d 70 61 73 63 61 6c 20 |ack);.}.|.pascal |
|00002550| 76 6f 69 64 20 5f 57 45 | 41 64 6a 75 73 74 55 6e |void _WE|AdjustUn|
|00002560| 64 6f 52 61 6e 67 65 28 | 53 49 6e 74 33 32 20 6d |doRange(|SInt32 m|
|00002570| 6f 72 65 42 79 74 65 73 | 2c 20 57 45 48 61 6e 64 |oreBytes|, WEHand|
|00002580| 6c 65 20 68 57 45 29 0d | 7b 0d 09 57 45 41 63 74 |le hWE).|{..WEAct|
|00002590| 69 6f 6e 48 61 6e 64 6c | 65 20 68 41 63 74 69 6f |ionHandl|e hActio|
|000025a0| 6e 3b 0d 0d 09 69 66 20 | 28 28 68 41 63 74 69 6f |n;...if |((hActio|
|000025b0| 6e 20 3d 20 28 2a 68 57 | 45 29 2d 3e 68 41 63 74 |n = (*hW|E)->hAct|
|000025c0| 69 6f 6e 53 74 61 63 6b | 29 20 21 3d 20 6e 69 6c |ionStack|) != nil|
|000025d0| 29 0d 09 7b 0d 09 09 28 | 2a 68 41 63 74 69 6f 6e |)..{...(|*hAction|
|000025e0| 29 2d 3e 64 65 6c 52 61 | 6e 67 65 4c 65 6e 67 74 |)->delRa|ngeLengt|
|000025f0| 68 20 2b 3d 20 6d 6f 72 | 65 42 79 74 65 73 3b 0d |h += mor|eBytes;.|
|00002600| 09 7d 0d 7d 0d 0d 70 61 | 73 63 61 6c 20 4f 53 45 |.}.}..pa|scal OSE|
|00002610| 72 72 20 5f 57 45 54 79 | 70 65 43 68 61 72 28 63 |rr _WETy|peChar(c|
|00002620| 68 61 72 20 74 68 65 42 | 79 74 65 2c 20 57 45 48 |har theB|yte, WEH|
|00002630| 61 6e 64 6c 65 20 68 57 | 45 29 0d 7b 0d 09 57 45 |andle hW|E).{..WE|
|00002640| 50 74 72 20 70 57 45 3b | 0d 09 63 68 61 72 20 64 |Ptr pWE;|..char d|
|00002650| 62 5b 32 5d 3b 0d 09 53 | 49 6e 74 33 32 20 6f 66 |b[2];..S|Int32 of|
|00002660| 66 73 65 74 2c 20 65 6e | 64 4f 66 66 73 65 74 2c |fset, en|dOffset,|
|00002670| 20 63 68 61 72 4c 65 6e | 67 74 68 3b 0d 09 4f 53 | charLen|gth;..OS|
|00002680| 45 72 72 20 65 72 72 3b | 0d 0d 09 70 57 45 20 3d |Err err;|...pWE =|
|00002690| 20 2a 68 57 45 3b 09 09 | 09 09 09 2f 2f 20 74 68 | *hWE;..|...// th|
|000026a0| 65 20 57 45 20 72 65 63 | 6f 72 64 20 6d 75 73 74 |e WE rec|ord must|
|000026b0| 20 62 65 20 61 6c 72 65 | 61 64 79 20 6c 6f 63 6b | be alre|ady lock|
|000026c0| 65 64 0d 09 63 68 61 72 | 4c 65 6e 67 74 68 20 3d |ed..char|Length =|
|000026d0| 20 31 3b 09 09 09 09 2f | 2f 20 61 73 73 75 6d 65 | 1;..../|/ assume|
|000026e0| 20 31 2d 62 79 74 65 20 | 63 68 61 72 61 63 74 65 | 1-byte |characte|
|000026f0| 72 20 62 79 20 64 65 66 | 61 75 6c 74 0d 09 64 62 |r by def|ault..db|
|00002700| 5b 30 5d 20 3d 20 74 68 | 65 42 79 74 65 3b 0d 09 |[0] = th|eByte;..|
|00002710| 6f 66 66 73 65 74 20 3d | 20 70 57 45 2d 3e 73 65 |offset =| pWE->se|
|00002720| 6c 53 74 61 72 74 3b 0d | 0d 09 2f 2f 20 64 65 6c |lStart;.|..// del|
|00002730| 65 74 65 20 63 75 72 72 | 65 6e 74 20 73 65 6c 65 |ete curr|ent sele|
|00002740| 63 74 69 6f 6e 2c 20 69 | 66 20 61 6e 79 0d 09 69 |ction, i|f any..i|
|00002750| 66 20 28 28 65 72 72 20 | 3d 20 5f 57 45 44 65 6c |f ((err |= _WEDel|
|00002760| 65 74 65 52 61 6e 67 65 | 28 6f 66 66 73 65 74 2c |eteRange|(offset,|
|00002770| 20 70 57 45 2d 3e 73 65 | 6c 45 6e 64 2c 20 68 57 | pWE->se|lEnd, hW|
|00002780| 45 29 29 20 21 3d 20 6e | 6f 45 72 72 29 0d 09 7b |E)) != n|oErr)..{|
|00002790| 0d 09 09 67 6f 74 6f 20 | 63 6c 65 61 6e 75 70 3b |...goto |cleanup;|
|000027a0| 0d 09 7d 0d 0d 09 70 57 | 45 2d 3e 73 65 6c 45 6e |..}...pW|E->selEn|
|000027b0| 64 20 3d 20 6f 66 66 73 | 65 74 3b 20 2f 2f 20 6e |d = offs|et; // n|
|000027c0| 65 65 64 65 64 20 69 6e | 20 63 61 73 65 20 77 65 |eeded in| case we|
|000027d0| 20 74 61 6b 65 20 61 20 | 70 72 65 6d 61 74 75 72 | take a |prematur|
|000027e0| 65 20 65 78 69 74 0d 0d | 09 2f 2f 20 6d 61 6b 65 |e exit..|.// make|
|000027f0| 20 73 75 72 65 20 74 68 | 65 20 66 6f 6e 74 20 73 | sure th|e font s|
|00002800| 63 72 69 70 74 20 69 73 | 20 73 79 6e 63 68 72 6f |cript is| synchro|
|00002810| 6e 69 7a 65 64 20 77 69 | 74 68 20 74 68 65 20 6b |nized wi|th the k|
|00002820| 65 79 62 6f 61 72 64 20 | 73 63 72 69 70 74 0d 09 |eyboard |script..|
|00002830| 5f 57 45 53 79 6e 63 68 | 4e 75 6c 6c 53 74 79 6c |_WESynch|NullStyl|
|00002840| 65 28 68 57 45 29 3b 0d | 0d 09 69 66 20 28 42 54 |e(hWE);.|..if (BT|
|00002850| 53 54 28 70 57 45 2d 3e | 66 6c 61 67 73 2c 20 77 |ST(pWE->|flags, w|
|00002860| 65 46 44 6f 75 62 6c 65 | 42 79 74 65 29 29 0d 09 |eFDouble|Byte))..|
|00002870| 7b 0d 0d 09 09 2f 2f 20 | 73 70 65 63 69 61 6c 20 |{....// |special |
|00002880| 70 72 6f 63 65 73 73 69 | 6e 67 20 66 6f 72 20 64 |processi|ng for d|
|00002890| 6f 75 62 6c 65 2d 62 79 | 74 65 20 63 68 61 72 61 |ouble-by|te chara|
|000028a0| 63 74 65 72 73 0d 09 09 | 69 66 20 28 70 57 45 2d |cters...|if (pWE-|
|000028b0| 3e 66 69 72 73 74 42 79 | 74 65 20 21 3d 20 30 29 |>firstBy|te != 0)|
|000028c0| 0d 09 09 7b 0d 0d 09 09 | 09 2f 2f 20 69 66 20 74 |...{....|.// if t|
|000028d0| 68 69 73 20 62 79 74 65 | 20 69 73 20 74 68 65 20 |his byte| is the |
|000028e0| 73 65 63 6f 6e 64 20 68 | 61 6c 66 20 6f 66 20 61 |second h|alf of a|
|000028f0| 20 64 6f 75 62 6c 65 2d | 62 79 74 65 20 63 68 61 | double-|byte cha|
|00002900| 72 61 63 74 65 72 2c 0d | 09 09 09 2f 2f 20 69 6e |racter,.|...// in|
|00002910| 73 65 72 74 20 74 68 65 | 20 74 77 6f 20 62 79 74 |sert the| two byt|
|00002920| 65 73 20 61 74 20 74 68 | 65 20 73 61 6d 65 20 74 |es at th|e same t|
|00002930| 69 6d 65 20 28 66 6c 75 | 73 68 20 74 68 65 20 64 |ime (flu|sh the d|
|00002940| 6f 75 62 6c 65 2d 62 79 | 74 65 20 63 61 63 68 65 |ouble-by|te cache|
|00002950| 29 0d 09 09 09 64 62 5b | 30 5d 20 3d 20 70 57 45 |)....db[|0] = pWE|
|00002960| 2d 3e 66 69 72 73 74 42 | 79 74 65 3b 0d 09 09 09 |->firstB|yte;....|
|00002970| 64 62 5b 31 5d 20 3d 20 | 74 68 65 42 79 74 65 3b |db[1] = |theByte;|
|00002980| 0d 09 09 09 63 68 61 72 | 4c 65 6e 67 74 68 20 3d |....char|Length =|
|00002990| 20 32 3b 0d 09 09 09 70 | 57 45 2d 3e 66 69 72 73 | 2;....p|WE->firs|
|000029a0| 74 42 79 74 65 20 3d 20 | 30 3b 0d 09 09 7d 0d 09 |tByte = |0;...}..|
|000029b0| 09 65 6c 73 65 0d 09 09 | 7b 0d 0d 09 09 09 2f 2f |.else...|{.....//|
|000029c0| 20 69 66 20 74 68 65 42 | 79 74 65 20 69 73 20 74 | if theB|yte is t|
|000029d0| 68 65 20 66 69 72 73 74 | 20 68 61 6c 66 20 6f 66 |he first| half of|
|000029e0| 20 61 20 64 6f 75 62 6c | 65 2d 62 79 74 65 20 63 | a doubl|e-byte c|
|000029f0| 68 61 72 61 63 74 65 72 | 2c 20 6a 75 73 74 20 63 |haracter|, just c|
|00002a00| 61 63 68 65 20 69 74 20 | 61 6e 64 20 65 78 69 74 |ache it |and exit|
|00002a10| 0d 09 09 09 69 66 20 28 | 43 61 6c 6c 57 45 43 68 |....if (|CallWECh|
|00002a20| 61 72 42 79 74 65 50 72 | 6f 63 28 26 74 68 65 42 |arBytePr|oc(&theB|
|00002a30| 79 74 65 2c 20 30 2c 20 | 46 6f 6e 74 54 6f 53 63 |yte, 0, |FontToSc|
|00002a40| 72 69 70 74 28 70 57 45 | 2d 3e 6e 75 6c 6c 53 74 |ript(pWE|->nullSt|
|00002a50| 79 6c 65 2e 72 75 6e 53 | 74 79 6c 65 2e 74 73 46 |yle.runS|tyle.tsF|
|00002a60| 6f 6e 74 29 2c 0d 09 09 | 09 09 68 57 45 2c 20 70 |ont),...|..hWE, p|
|00002a70| 57 45 2d 3e 63 68 61 72 | 42 79 74 65 48 6f 6f 6b |WE->char|ByteHook|
|00002a80| 29 20 3d 3d 20 73 6d 46 | 69 72 73 74 42 79 74 65 |) == smF|irstByte|
|00002a90| 29 0d 09 09 09 7b 0d 09 | 09 09 09 70 57 45 2d 3e |)....{..|...pWE->|
|00002aa0| 66 69 72 73 74 42 79 74 | 65 20 3d 20 74 68 65 42 |firstByt|e = theB|
|00002ab0| 79 74 65 3b 0d 09 09 09 | 09 72 65 74 75 72 6e 20 |yte;....|.return |
|00002ac0| 6e 6f 45 72 72 3b 0d 09 | 09 09 7d 0d 09 09 7d 0d |noErr;..|..}...}.|
|00002ad0| 0d 09 7d 20 2f 2f 20 69 | 66 20 64 6f 75 62 6c 65 |..} // i|f double|
|00002ae0| 2d 62 79 74 65 20 73 63 | 72 69 70 74 20 69 6e 73 |-byte sc|ript ins|
|00002af0| 74 61 6c 6c 65 64 0d 0d | 09 2f 2f 20 69 6e 73 65 |talled..|.// inse|
|00002b00| 72 74 20 74 68 65 20 6e | 65 77 20 63 68 61 72 61 |rt the n|ew chara|
|00002b10| 63 74 65 72 20 69 6e 74 | 6f 20 74 68 65 20 74 65 |cter int|o the te|
|00002b20| 78 74 0d 09 69 66 20 28 | 28 65 72 72 20 3d 20 5f |xt..if (|(err = _|
|00002b30| 57 45 49 6e 73 65 72 74 | 54 65 78 74 28 6f 66 66 |WEInsert|Text(off|
|00002b40| 73 65 74 2c 20 64 62 2c | 20 63 68 61 72 4c 65 6e |set, db,| charLen|
|00002b50| 67 74 68 2c 20 68 57 45 | 29 29 20 21 3d 20 6e 6f |gth, hWE|)) != no|
|00002b60| 45 72 72 29 0d 09 7b 0d | 09 09 67 6f 74 6f 20 63 |Err)..{.|..goto c|
|00002b70| 6c 65 61 6e 75 70 3b 0d | 09 7d 0d 0d 09 2f 2f 20 |leanup;.|.}...// |
|00002b80| 61 64 6a 75 73 74 20 75 | 6e 64 6f 20 62 75 66 66 |adjust u|ndo buff|
|00002b90| 65 72 20 66 6f 72 20 74 | 68 65 20 6e 65 77 20 63 |er for t|he new c|
|00002ba0| 68 61 72 61 63 74 65 72 | 0d 09 5f 57 45 41 64 6a |haracter|.._WEAdj|
|00002bb0| 75 73 74 55 6e 64 6f 52 | 61 6e 67 65 28 63 68 61 |ustUndoR|ange(cha|
|00002bc0| 72 4c 65 6e 67 74 68 2c | 20 68 57 45 29 3b 0d 0d |rLength,| hWE);..|
|00002bd0| 09 2f 2f 20 69 6e 76 61 | 6c 69 64 20 74 68 65 20 |.// inva|lid the |
|00002be0| 6e 75 6c 6c 20 73 74 79 | 6c 65 0d 09 42 43 4c 52 |null sty|le..BCLR|
|00002bf0| 28 70 57 45 2d 3e 66 6c | 61 67 73 2c 20 77 65 46 |(pWE->fl|ags, weF|
|00002c00| 55 73 65 4e 75 6c 6c 53 | 74 79 6c 65 29 3b 0d 0d |UseNullS|tyle);..|
|00002c10| 09 2f 2f 20 6d 6f 76 65 | 20 74 68 65 20 69 6e 73 |.// move| the ins|
|00002c20| 65 72 74 69 6f 6e 20 70 | 6f 69 6e 74 20 61 66 74 |ertion p|oint aft|
|00002c30| 65 72 20 74 68 65 20 6e | 65 77 20 63 68 61 72 61 |er the n|ew chara|
|00002c40| 63 74 65 72 0d 09 65 6e | 64 4f 66 66 73 65 74 20 |cter..en|dOffset |
|00002c50| 3d 20 6f 66 66 73 65 74 | 20 2b 20 63 68 61 72 4c |= offset| + charL|
|00002c60| 65 6e 67 74 68 3b 0d 09 | 70 57 45 2d 3e 73 65 6c |ength;..|pWE->sel|
|00002c70| 53 74 61 72 74 20 3d 20 | 65 6e 64 4f 66 66 73 65 |Start = |endOffse|
|00002c80| 74 3b 0d 09 70 57 45 2d | 3e 73 65 6c 45 6e 64 20 |t;..pWE-|>selEnd |
|00002c90| 3d 20 65 6e 64 4f 66 66 | 73 65 74 3b 0d 0d 09 2f |= endOff|set;.../|
|00002ca0| 2f 20 72 65 64 72 61 77 | 20 74 68 65 20 74 65 78 |/ redraw| the tex|
|00002cb0| 74 0d 09 69 66 20 28 28 | 65 72 72 20 3d 20 5f 57 |t..if ((|err = _W|
|00002cc0| 45 52 65 64 72 61 77 28 | 6f 66 66 73 65 74 2c 20 |ERedraw(|offset, |
|00002cd0| 65 6e 64 4f 66 66 73 65 | 74 2c 20 68 57 45 29 29 |endOffse|t, hWE))|
|00002ce0| 20 21 3d 20 6e 6f 45 72 | 72 29 0d 09 7b 0d 09 09 | != noEr|r)..{...|
|00002cf0| 67 6f 74 6f 20 63 6c 65 | 61 6e 75 70 3b 0d 09 7d |goto cle|anup;..}|
|00002d00| 0d 0d 09 2f 2f 20 63 6c | 65 61 72 20 72 65 73 75 |...// cl|ear resu|
|00002d10| 6c 74 20 63 6f 64 65 0d | 09 65 72 72 20 3d 20 6e |lt code.|.err = n|
|00002d20| 6f 45 72 72 3b 0d 0d 63 | 6c 65 61 6e 75 70 3a 0d |oErr;..c|leanup:.|
|00002d30| 09 2f 2f 20 72 65 74 75 | 72 6e 20 72 65 73 75 6c |.// retu|rn resul|
|00002d40| 74 20 63 6f 64 65 0d 09 | 72 65 74 75 72 6e 20 65 |t code..|return e|
|00002d50| 72 72 3b 0d 0d 7d 0d 0d | 70 61 73 63 61 6c 20 4f |rr;..}..|pascal O|
|00002d60| 53 45 72 72 20 5f 57 45 | 42 61 63 6b 73 70 61 63 |SErr _WE|Backspac|
|00002d70| 65 28 57 45 48 61 6e 64 | 6c 65 20 68 57 45 29 0d |e(WEHand|le hWE).|
|00002d80| 7b 0d 09 2f 2f 20 74 68 | 69 73 20 72 6f 75 74 69 |{..// th|is routi|
|00002d90| 6e 65 20 69 73 20 63 61 | 6c 6c 65 64 20 62 79 20 |ne is ca|lled by |
|00002da0| 57 45 4b 65 79 20 74 6f | 20 68 61 6e 64 6c 65 20 |WEKey to| handle |
|00002db0| 74 68 65 20 62 61 63 6b | 73 70 61 63 65 20 6b 65 |the back|space ke|
|00002dc0| 79 0d 0d 09 57 45 50 74 | 72 20 70 57 45 20 3d 20 |y...WEPt|r pWE = |
|00002dd0| 2a 68 57 45 3b 09 2f 2f | 20 61 73 73 75 6d 65 20 |*hWE;.//| assume |
|00002de0| 57 45 20 72 65 63 6f 72 | 64 20 69 73 20 61 6c 72 |WE recor|d is alr|
|00002df0| 65 61 64 79 20 6c 6f 63 | 6b 65 64 0d 09 57 45 41 |eady loc|ked..WEA|
|00002e00| 63 74 69 6f 6e 20 2a 70 | 41 63 74 69 6f 6e 3b 0d |ction *p|Action;.|
|00002e10| 09 53 49 6e 74 33 32 20 | 72 61 6e 67 65 53 74 61 |.SInt32 |rangeSta|
|00002e20| 72 74 2c 20 72 61 6e 67 | 65 45 6e 64 2c 20 63 68 |rt, rang|eEnd, ch|
|00002e30| 61 72 4c 65 6e 67 74 68 | 3b 0d 09 57 45 52 75 6e |arLength|;..WERun|
|00002e40| 49 6e 66 6f 50 72 69 76 | 20 72 75 6e 49 6e 66 6f |InfoPriv| runInfo|
|00002e50| 3b 0d 09 63 68 61 72 20 | 64 62 5b 32 5d 3b 0d 09 |;..char |db[2];..|
|00002e60| 42 6f 6f 6c 65 61 6e 20 | 73 61 76 65 41 63 74 69 |Boolean |saveActi|
|00002e70| 6f 6e 4c 6f 63 6b 3b 0d | 09 4f 53 45 72 72 20 65 |onLock;.|.OSErr e|
|00002e80| 72 72 3b 0d 0d 09 2f 2f | 20 63 61 6c 63 75 6c 61 |rr;...//| calcula|
|00002e90| 74 65 20 74 68 65 20 74 | 65 78 74 20 72 61 6e 67 |te the t|ext rang|
|00002ea0| 65 20 74 6f 20 64 65 6c | 65 74 65 0d 09 2f 2f 20 |e to del|ete..// |
|00002eb0| 69 66 20 74 68 65 20 73 | 65 6c 65 63 74 69 6f 6e |if the s|election|
|00002ec0| 20 69 73 20 6e 6f 6e 2d | 65 6d 70 74 79 2c 20 64 | is non-|empty, d|
|00002ed0| 65 6c 65 74 65 20 74 68 | 61 74 0d 09 72 61 6e 67 |elete th|at..rang|
|00002ee0| 65 53 74 61 72 74 20 3d | 20 70 57 45 2d 3e 73 65 |eStart =| pWE->se|
|00002ef0| 6c 53 74 61 72 74 3b 0d | 09 72 61 6e 67 65 45 6e |lStart;.|.rangeEn|
|00002f00| 64 20 3d 20 70 57 45 2d | 3e 73 65 6c 45 6e 64 3b |d = pWE-|>selEnd;|
|00002f10| 0d 09 69 66 20 28 72 61 | 6e 67 65 53 74 61 72 74 |..if (ra|ngeStart|
|00002f20| 20 3d 3d 20 72 61 6e 67 | 65 45 6e 64 29 0d 09 7b | == rang|eEnd)..{|
|00002f30| 0d 0d 09 09 2f 2f 20 6f | 74 68 65 72 77 69 73 65 |....// o|therwise|
|00002f40| 20 74 68 65 20 73 65 6c | 65 63 74 69 6f 6e 20 69 | the sel|ection i|
|00002f50| 73 20 61 6e 20 69 6e 73 | 65 72 74 69 6f 6e 20 70 |s an ins|ertion p|
|00002f60| 6f 69 6e 74 0d 09 09 2f | 2f 20 64 6f 20 6e 6f 74 |oint.../|/ do not|
|00002f70| 68 69 6e 67 20 69 66 20 | 69 6e 73 65 72 74 69 6f |hing if |insertio|
|00002f80| 6e 20 70 6f 69 6e 74 20 | 69 73 20 61 74 20 74 68 |n point |is at th|
|00002f90| 65 20 62 65 67 69 6e 6e | 69 6e 67 20 6f 66 20 74 |e beginn|ing of t|
|00002fa0| 68 65 20 74 65 78 74 0d | 09 09 69 66 20 28 72 61 |he text.|..if (ra|
|00002fb0| 6e 67 65 53 74 61 72 74 | 20 3d 3d 20 30 29 0d 09 |ngeStart| == 0)..|
|00002fc0| 09 7b 0d 09 09 09 72 65 | 74 75 72 6e 20 6e 6f 45 |.{....re|turn noE|
|00002fd0| 72 72 3b 0d 09 09 7d 0d | 0d 09 09 2f 2f 20 64 65 |rr;...}.|...// de|
|00002fe0| 74 65 72 6d 69 6e 65 20 | 74 68 65 20 62 79 74 65 |termine |the byte|
|00002ff0| 2d 74 79 70 65 20 6f 66 | 20 74 68 65 20 63 68 61 |-type of| the cha|
|00003000| 72 61 63 74 65 72 20 70 | 72 65 63 65 64 69 6e 67 |racter p|receding|
|00003010| 20 74 68 65 20 69 6e 73 | 65 72 74 69 6f 6e 20 70 | the ins|ertion p|
|00003020| 6f 69 6e 74 0d 09 09 63 | 68 61 72 4c 65 6e 67 74 |oint...c|harLengt|
|00003030| 68 20 3d 20 28 57 45 43 | 68 61 72 42 79 74 65 28 |h = (WEC|harByte(|
|00003040| 72 61 6e 67 65 53 74 61 | 72 74 20 2d 20 31 2c 20 |rangeSta|rt - 1, |
|00003050| 68 57 45 29 20 3d 3d 20 | 73 6d 53 69 6e 67 6c 65 |hWE) == |smSingle|
|00003060| 42 79 74 65 29 20 3f 20 | 31 20 3a 20 32 3b 0d 09 |Byte) ? |1 : 2;..|
|00003070| 09 72 61 6e 67 65 53 74 | 61 72 74 20 2d 3d 20 63 |.rangeSt|art -= c|
|00003080| 68 61 72 4c 65 6e 67 74 | 68 3b 0d 0d 09 09 69 66 |harLengt|h;....if|
|00003090| 20 28 70 57 45 2d 3e 68 | 41 63 74 69 6f 6e 53 74 | (pWE->h|ActionSt|
|000030a0| 61 63 6b 20 21 3d 20 6e | 69 6c 29 0d 09 09 7b 0d |ack != n|il)...{.|
|000030b0| 09 09 09 2f 2f 20 55 4e | 44 4f 20 53 55 50 50 4f |...// UN|DO SUPPO|
|000030c0| 52 54 20 46 4f 52 20 42 | 41 43 4b 53 50 41 43 45 |RT FOR B|ACKSPACE|
|000030d0| 53 0d 0d 09 09 09 2f 2f | 20 6c 6f 63 6b 20 74 68 |S.....//| lock th|
|000030e0| 65 20 61 63 74 69 6f 6e | 20 72 65 63 6f 72 64 0d |e action| record.|
|000030f0| 09 09 09 73 61 76 65 41 | 63 74 69 6f 6e 4c 6f 63 |...saveA|ctionLoc|
|00003100| 6b 20 3d 20 5f 57 45 53 | 65 74 48 61 6e 64 6c 65 |k = _WES|etHandle|
|00003110| 4c 6f 63 6b 28 28 48 61 | 6e 64 6c 65 29 20 70 57 |Lock((Ha|ndle) pW|
|00003120| 45 2d 3e 68 41 63 74 69 | 6f 6e 53 74 61 63 6b 2c |E->hActi|onStack,|
|00003130| 20 74 72 75 65 29 3b 0d | 09 09 09 70 41 63 74 69 | true);.|...pActi|
|00003140| 6f 6e 20 3d 20 2a 70 57 | 45 2d 3e 68 41 63 74 69 |on = *pW|E->hActi|
|00003150| 6f 6e 53 74 61 63 6b 3b | 0d 0d 09 09 09 2f 2f 20 |onStack;|.....// |
|00003160| 62 61 63 6b 73 70 61 63 | 65 73 20 6f 76 65 72 20 |backspac|es over |
|00003170| 74 68 65 20 6e 65 77 6c | 79 20 65 6e 74 65 72 65 |the newl|y entere|
|00003180| 64 20 74 65 78 74 20 61 | 72 65 6e 27 74 20 61 20 |d text a|ren't a |
|00003190| 70 72 6f 62 6c 65 6d 0d | 09 09 09 69 66 20 28 70 |problem.|...if (p|
|000031a0| 41 63 74 69 6f 6e 2d 3e | 64 65 6c 52 61 6e 67 65 |Action->|delRange|
|000031b0| 4c 65 6e 67 74 68 20 3e | 20 30 29 0d 09 09 09 7b |Length >| 0)....{|
|000031c0| 0d 09 09 09 09 70 41 63 | 74 69 6f 6e 2d 3e 64 65 |.....pAc|tion->de|
|000031d0| 6c 52 61 6e 67 65 4c 65 | 6e 67 74 68 20 2d 3d 20 |lRangeLe|ngth -= |
|000031e0| 63 68 61 72 4c 65 6e 67 | 74 68 3b 0d 09 09 09 7d |charLeng|th;....}|
|000031f0| 0d 09 09 09 65 6c 73 65 | 0d 09 09 09 7b 0d 0d 09 |....else|....{...|
|00003200| 09 09 09 2f 2f 20 74 68 | 65 20 68 61 72 64 20 70 |...// th|e hard p|
|00003210| 61 72 74 20 63 6f 6d 65 | 73 20 77 68 65 6e 20 62 |art come|s when b|
|00003220| 61 63 6b 73 70 61 63 69 | 6e 67 20 70 61 73 74 20 |ackspaci|ng past |
|00003230| 74 68 65 20 6e 65 77 20 | 74 65 78 74 20 62 65 63 |the new |text bec|
|00003240| 61 75 73 65 0d 09 09 09 | 09 2f 2f 20 74 68 65 20 |ause....|.// the |
|00003250| 75 73 65 72 20 69 73 20 | 61 62 6f 75 74 20 74 6f |user is |about to|
|00003260| 20 64 65 6c 65 74 65 20 | 61 20 63 68 61 72 61 63 | delete |a charac|
|00003270| 74 65 72 20 6e 6f 74 20 | 69 6e 63 6c 75 64 65 64 |ter not |included|
|00003280| 20 69 6e 20 74 68 65 20 | 62 6c 6f 63 6b 20 77 65 | in the |block we|
|00003290| 20 73 61 76 65 64 0d 09 | 09 09 09 64 62 5b 30 5d | saved..|...db[0]|
|000032a0| 20 3d 20 57 45 47 65 74 | 43 68 61 72 28 72 61 6e | = WEGet|Char(ran|
|000032b0| 67 65 53 74 61 72 74 2c | 20 68 57 45 29 3b 0d 09 |geStart,| hWE);..|
|000032c0| 09 09 09 69 66 20 28 63 | 68 61 72 4c 65 6e 67 74 |...if (c|harLengt|
|000032d0| 68 20 3d 3d 20 32 29 0d | 09 09 09 09 7b 0d 09 09 |h == 2).|....{...|
|000032e0| 09 09 09 64 62 5b 31 5d | 20 3d 20 57 45 47 65 74 |...db[1]| = WEGet|
|000032f0| 43 68 61 72 28 72 61 6e | 67 65 53 74 61 72 74 20 |Char(ran|geStart |
|00003300| 2b 20 31 2c 20 68 57 45 | 29 3b 0d 09 09 09 09 7d |+ 1, hWE|);.....}|
|00003310| 0d 0d 09 09 09 09 2f 2f | 20 70 72 65 70 65 6e 64 |......//| prepend|
|00003320| 20 74 68 65 20 63 68 61 | 72 61 63 74 65 72 20 74 | the cha|racter t|
|00003330| 6f 20 62 65 20 64 65 6c | 65 74 65 64 20 74 6f 20 |o be del|eted to |
|00003340| 74 68 65 20 62 65 67 69 | 6e 6e 69 6e 67 20 6f 66 |the begi|nning of|
|00003350| 20 6f 75 72 20 73 61 76 | 65 64 20 74 65 78 74 20 | our sav|ed text |
|00003360| 68 61 6e 64 6c 65 0d 09 | 09 09 09 69 66 20 28 28 |handle..|...if ((|
|00003370| 65 72 72 20 3d 20 5f 57 | 45 53 70 6c 69 63 65 28 |err = _W|ESplice(|
|00003380| 70 41 63 74 69 6f 6e 2d | 3e 68 54 65 78 74 2c 20 |pAction-|>hText, |
|00003390| 26 64 62 2c 20 63 68 61 | 72 4c 65 6e 67 74 68 2c |&db, cha|rLength,|
|000033a0| 20 30 29 29 20 21 3d 20 | 6e 6f 45 72 72 29 0d 09 | 0)) != |noErr)..|
|000033b0| 09 09 09 7b 0d 09 09 09 | 09 09 72 65 74 75 72 6e |...{....|..return|
|000033c0| 20 65 72 72 3b 0d 09 09 | 09 09 7d 0d 0d 09 09 09 | err;...|..}.....|
|000033d0| 09 2f 2f 20 61 64 6a 75 | 73 74 20 69 6e 74 65 72 |.// adju|st inter|
|000033e0| 6e 61 6c 20 63 6f 75 6e | 74 65 72 73 0d 09 09 09 |nal coun|ters....|
|000033f0| 09 70 41 63 74 69 6f 6e | 2d 3e 69 6e 73 52 61 6e |.pAction|->insRan|
|00003400| 67 65 4c 65 6e 67 74 68 | 20 2b 3d 20 63 68 61 72 |geLength| += char|
|00003410| 4c 65 6e 67 74 68 3b 0d | 09 09 09 09 70 41 63 74 |Length;.|....pAct|
|00003420| 69 6f 6e 2d 3e 64 65 6c | 52 61 6e 67 65 53 74 61 |ion->del|RangeSta|
|00003430| 72 74 20 2d 3d 20 63 68 | 61 72 4c 65 6e 67 74 68 |rt -= ch|arLength|
|00003440| 3b 0d 0d 09 09 09 09 2f | 2f 20 67 65 74 20 73 74 |;....../|/ get st|
|00003450| 79 6c 65 20 72 75 6e 20 | 69 6e 66 6f 20 61 73 73 |yle run |info ass|
|00003460| 6f 63 69 61 74 65 64 20 | 77 69 74 68 20 74 68 65 |ociated |with the|
|00003470| 20 61 62 6f 75 74 2d 74 | 6f 2d 62 65 2d 64 65 6c | about-t|o-be-del|
|00003480| 65 74 65 64 20 63 68 61 | 72 61 63 74 65 72 0d 09 |eted cha|racter..|
|00003490| 09 09 09 57 45 47 65 74 | 52 75 6e 49 6e 66 6f 28 |...WEGet|RunInfo(|
|000034a0| 72 61 6e 67 65 53 74 61 | 72 74 2c 20 28 57 45 52 |rangeSta|rt, (WER|
|000034b0| 75 6e 49 6e 66 6f 20 2a | 29 26 72 75 6e 49 6e 66 |unInfo *|)&runInf|
|000034c0| 6f 2c 20 68 57 45 29 3b | 0d 0d 09 09 09 09 2f 2f |o, hWE);|......//|
|000034d0| 20 70 72 65 70 65 6e 64 | 20 61 20 6e 65 77 20 73 | prepend| a new s|
|000034e0| 74 79 6c 65 20 65 6c 65 | 6d 65 6e 74 20 74 6f 20 |tyle ele|ment to |
|000034f0| 6f 75 72 20 73 74 79 6c | 65 20 73 63 72 61 70 2c |our styl|e scrap,|
|00003500| 20 69 66 20 6e 65 63 65 | 73 73 61 72 79 0d 09 09 | if nece|ssary...|
|00003510| 09 09 69 66 20 28 28 65 | 72 72 20 3d 20 5f 57 45 |..if ((e|rr = _WE|
|00003520| 50 72 65 70 65 6e 64 53 | 74 79 6c 65 28 70 41 63 |PrependS|tyle(pAc|
|00003530| 74 69 6f 6e 2d 3e 68 53 | 74 79 6c 65 73 2c 20 26 |tion->hS|tyles, &|
|00003540| 72 75 6e 49 6e 66 6f 2c | 20 63 68 61 72 4c 65 6e |runInfo,| charLen|
|00003550| 67 74 68 29 29 20 21 3d | 20 6e 6f 45 72 72 29 0d |gth)) !=| noErr).|
|00003560| 09 09 09 09 7b 0d 09 09 | 09 09 09 72 65 74 75 72 |....{...|...retur|
|00003570| 6e 20 65 72 72 3b 0d 09 | 09 09 09 7d 0d 0d 23 69 |n err;..|...}..#i|
|00003580| 66 20 57 41 53 54 45 5f | 4f 42 4a 45 43 54 53 0d |f WASTE_|OBJECTS.|
|00003590| 09 09 09 09 2f 2f 20 64 | 6f 20 74 68 65 20 73 61 |....// d|o the sa|
|000035a0| 6d 65 20 77 69 74 68 20 | 6f 75 72 20 6f 62 6a 65 |me with |our obje|
|000035b0| 63 74 20 22 73 6f 75 70 | 22 0d 09 09 09 09 69 66 |ct "soup|".....if|
|000035c0| 20 28 28 65 72 72 20 3d | 20 5f 57 45 50 72 65 70 | ((err =| _WEPrep|
|000035d0| 65 6e 64 4f 62 6a 65 63 | 74 28 70 41 63 74 69 6f |endObjec|t(pActio|
|000035e0| 6e 2d 3e 68 53 6f 75 70 | 2c 20 26 72 75 6e 49 6e |n->hSoup|, &runIn|
|000035f0| 66 6f 2c 20 63 68 61 72 | 4c 65 6e 67 74 68 29 29 |fo, char|Length))|
|00003600| 20 21 3d 20 6e 6f 45 72 | 72 29 0d 09 09 09 09 7b | != noEr|r).....{|
|00003610| 0d 09 09 09 09 09 72 65 | 74 75 72 6e 20 65 72 72 |......re|turn err|
|00003620| 3b 0d 09 09 09 09 7d 0d | 23 65 6e 64 69 66 0d 0d |;.....}.|#endif..|
|00003630| 09 09 09 7d 20 2f 2f 20 | 69 66 20 64 65 6c 65 74 |...} // |if delet|
|00003640| 69 6e 67 20 6f 6c 64 20 | 74 65 78 74 0d 0d 09 09 |ing old |text....|
|00003650| 09 2f 2f 20 75 6e 6c 6f | 63 6b 20 74 68 65 20 61 |.// unlo|ck the a|
|00003660| 63 74 69 6f 6e 20 72 65 | 63 6f 72 64 0d 09 09 09 |ction re|cord....|
|00003670| 5f 57 45 53 65 74 48 61 | 6e 64 6c 65 4c 6f 63 6b |_WESetHa|ndleLock|
|00003680| 28 28 48 61 6e 64 6c 65 | 29 20 70 57 45 2d 3e 68 |((Handle|) pWE->h|
|00003690| 41 63 74 69 6f 6e 53 74 | 61 63 6b 2c 20 73 61 76 |ActionSt|ack, sav|
|000036a0| 65 41 63 74 69 6f 6e 4c | 6f 63 6b 29 3b 0d 0d 09 |eActionL|ock);...|
|000036b0| 09 7d 20 2f 2f 20 69 66 | 20 75 6e 64 6f 20 73 75 |.} // if| undo su|
|000036c0| 70 70 6f 72 74 20 69 73 | 20 65 6e 61 62 6c 65 64 |pport is| enabled|
|000036d0| 0d 09 7d 20 2f 2f 20 69 | 66 20 73 65 6c 65 63 74 |..} // i|f select|
|000036e0| 69 6f 6e 20 69 73 20 65 | 6d 70 74 79 0d 0d 09 69 |ion is e|mpty...i|
|000036f0| 66 20 28 28 65 72 72 20 | 3d 20 5f 57 45 44 65 6c |f ((err |= _WEDel|
|00003700| 65 74 65 52 61 6e 67 65 | 28 72 61 6e 67 65 53 74 |eteRange|(rangeSt|
|00003710| 61 72 74 2c 20 72 61 6e | 67 65 45 6e 64 2c 20 68 |art, ran|geEnd, h|
|00003720| 57 45 29 29 20 21 3d 20 | 6e 6f 45 72 72 29 0d 09 |WE)) != |noErr)..|
|00003730| 7b 0d 09 09 72 65 74 75 | 72 6e 20 65 72 72 3b 0d |{...retu|rn err;.|
|00003740| 09 7d 0d 0d 09 2f 2f 20 | 6b 65 65 70 20 74 72 61 |.}...// |keep tra|
|00003750| 63 6b 20 6f 66 20 63 75 | 72 72 65 6e 74 20 73 65 |ck of cu|rrent se|
|00003760| 6c 65 63 74 69 6f 6e 20 | 72 61 6e 67 65 0d 09 70 |lection |range..p|
|00003770| 57 45 2d 3e 73 65 6c 53 | 74 61 72 74 20 3d 20 72 |WE->selS|tart = r|
|00003780| 61 6e 67 65 53 74 61 72 | 74 3b 0d 09 70 57 45 2d |angeStar|t;..pWE-|
|00003790| 3e 73 65 6c 45 6e 64 20 | 3d 20 72 61 6e 67 65 53 |>selEnd |= rangeS|
|000037a0| 74 61 72 74 3b 0d 0d 09 | 2f 2f 20 72 65 64 72 61 |tart;...|// redra|
|000037b0| 77 20 74 68 65 20 74 65 | 78 74 0d 09 65 72 72 20 |w the te|xt..err |
|000037c0| 3d 20 5f 57 45 52 65 64 | 72 61 77 28 72 61 6e 67 |= _WERed|raw(rang|
|000037d0| 65 53 74 61 72 74 2c 20 | 72 61 6e 67 65 53 74 61 |eStart, |rangeSta|
|000037e0| 72 74 2c 20 68 57 45 29 | 3b 0d 0d 09 72 65 74 75 |rt, hWE)|;...retu|
|000037f0| 72 6e 20 65 72 72 3b 0d | 7d 0d 0d 70 61 73 63 61 |rn err;.|}..pasca|
|00003800| 6c 20 4f 53 45 72 72 20 | 5f 57 45 46 6f 72 77 61 |l OSErr |_WEForwa|
|00003810| 72 64 44 65 6c 65 74 65 | 28 57 45 48 61 6e 64 6c |rdDelete|(WEHandl|
|00003820| 65 20 68 57 45 29 0d 7b | 0d 0d 09 2f 2f 20 74 68 |e hWE).{|...// th|
|00003830| 69 73 20 72 6f 75 74 69 | 6e 65 20 69 73 20 63 61 |is routi|ne is ca|
|00003840| 6c 6c 65 64 20 62 79 20 | 57 45 4b 65 79 20 74 6f |lled by |WEKey to|
|00003850| 20 68 61 6e 64 6c 65 20 | 74 68 65 20 66 6f 72 77 | handle |the forw|
|00003860| 61 72 64 20 64 65 6c 65 | 74 65 20 6b 65 79 0d 0d |ard dele|te key..|
|00003870| 09 57 45 50 74 72 20 70 | 57 45 20 3d 20 2a 68 57 |.WEPtr p|WE = *hW|
|00003880| 45 3b 09 2f 2f 20 61 73 | 73 75 6d 65 20 57 45 20 |E;.// as|sume WE |
|00003890| 72 65 63 6f 72 64 20 69 | 73 20 61 6c 72 65 61 64 |record i|s alread|
|000038a0| 79 20 6c 6f 63 6b 65 64 | 0d 09 57 45 41 63 74 69 |y locked|..WEActi|
|000038b0| 6f 6e 20 2a 70 41 63 74 | 69 6f 6e 3b 0d 09 53 49 |on *pAct|ion;..SI|
|000038c0| 6e 74 33 32 20 72 61 6e | 67 65 53 74 61 72 74 2c |nt32 ran|geStart,|
|000038d0| 20 72 61 6e 67 65 45 6e | 64 2c 20 63 68 61 72 4c | rangeEn|d, charL|
|000038e0| 65 6e 67 74 68 3b 0d 09 | 57 45 52 75 6e 49 6e 66 |ength;..|WERunInf|
|000038f0| 6f 50 72 69 76 20 72 75 | 6e 49 6e 66 6f 3b 0d 09 |oPriv ru|nInfo;..|
|00003900| 63 68 61 72 20 64 62 5b | 32 5d 3b 0d 09 42 6f 6f |char db[|2];..Boo|
|00003910| 6c 65 61 6e 20 73 61 76 | 65 41 63 74 69 6f 6e 4c |lean sav|eActionL|
|00003920| 6f 63 6b 3b 0d 09 4f 53 | 45 72 72 20 65 72 72 3b |ock;..OS|Err err;|
|00003930| 0d 0d 09 2f 2f 20 63 61 | 6c 63 75 6c 61 74 65 20 |...// ca|lculate |
|00003940| 74 68 65 20 74 65 78 74 | 20 72 61 6e 67 65 20 74 |the text| range t|
|00003950| 6f 20 64 65 6c 65 74 65 | 0d 09 2f 2f 20 69 66 20 |o delete|..// if |
|00003960| 74 68 65 20 73 65 6c 65 | 63 74 69 6f 6e 20 69 73 |the sele|ction is|
|00003970| 20 6e 6f 6e 2d 65 6d 70 | 74 79 2c 20 64 65 6c 65 | non-emp|ty, dele|
|00003980| 74 65 20 74 68 61 74 0d | 09 72 61 6e 67 65 53 74 |te that.|.rangeSt|
|00003990| 61 72 74 20 3d 20 70 57 | 45 2d 3e 73 65 6c 53 74 |art = pW|E->selSt|
|000039a0| 61 72 74 3b 0d 09 72 61 | 6e 67 65 45 6e 64 20 3d |art;..ra|ngeEnd =|
|000039b0| 20 70 57 45 2d 3e 73 65 | 6c 45 6e 64 3b 0d 09 69 | pWE->se|lEnd;..i|
|000039c0| 66 20 28 72 61 6e 67 65 | 53 74 61 72 74 20 3d 3d |f (range|Start ==|
|000039d0| 20 72 61 6e 67 65 45 6e | 64 29 0d 09 7b 0d 0d 09 | rangeEn|d)..{...|
|000039e0| 09 2f 2f 20 6f 74 68 65 | 72 77 69 73 65 20 74 68 |.// othe|rwise th|
|000039f0| 65 20 73 65 6c 65 63 74 | 69 6f 6e 20 69 73 20 61 |e select|ion is a|
|00003a00| 6e 20 69 6e 73 65 72 74 | 69 6f 6e 20 70 6f 69 6e |n insert|ion poin|
|00003a10| 74 0d 09 09 2f 2f 20 64 | 6f 20 6e 6f 74 68 69 6e |t...// d|o nothin|
|00003a20| 67 20 69 66 20 69 6e 73 | 65 72 74 69 6f 6e 20 70 |g if ins|ertion p|
|00003a30| 6f 69 6e 74 20 69 73 20 | 61 74 20 74 68 65 20 65 |oint is |at the e|
|00003a40| 6e 64 20 6f 66 20 74 68 | 65 20 74 65 78 74 0d 09 |nd of th|e text..|
|00003a50| 09 69 66 20 28 72 61 6e | 67 65 53 74 61 72 74 20 |.if (ran|geStart |
|00003a60| 3d 3d 20 70 57 45 2d 3e | 74 65 78 74 4c 65 6e 67 |== pWE->|textLeng|
|00003a70| 74 68 29 0d 09 09 7b 0d | 09 09 09 72 65 74 75 72 |th)...{.|...retur|
|00003a80| 6e 20 6e 6f 45 72 72 3b | 0d 09 09 7d 0d 0d 09 09 |n noErr;|...}....|
|00003a90| 2f 2f 20 64 65 74 65 72 | 6d 69 6e 65 20 74 68 65 |// deter|mine the|
|00003aa0| 20 62 79 74 65 2d 74 79 | 70 65 20 6f 66 20 74 68 | byte-ty|pe of th|
|00003ab0| 65 20 63 68 61 72 61 63 | 74 65 72 20 66 6f 6c 6c |e charac|ter foll|
|00003ac0| 6f 77 69 6e 67 20 74 68 | 65 20 69 6e 73 65 72 74 |owing th|e insert|
|00003ad0| 69 6f 6e 20 70 6f 69 6e | 74 0d 09 09 63 68 61 72 |ion poin|t...char|
|00003ae0| 4c 65 6e 67 74 68 20 3d | 20 28 57 45 43 68 61 72 |Length =| (WEChar|
|00003af0| 42 79 74 65 28 72 61 6e | 67 65 53 74 61 72 74 2c |Byte(ran|geStart,|
|00003b00| 20 68 57 45 29 20 3d 3d | 20 73 6d 53 69 6e 67 6c | hWE) ==| smSingl|
|00003b10| 65 42 79 74 65 29 20 3f | 20 31 20 3a 20 32 3b 0d |eByte) ?| 1 : 2;.|
|00003b20| 09 09 72 61 6e 67 65 45 | 6e 64 20 3d 20 72 61 6e |..rangeE|nd = ran|
|00003b30| 67 65 53 74 61 72 74 20 | 2b 20 63 68 61 72 4c 65 |geStart |+ charLe|
|00003b40| 6e 67 74 68 3b 0d 0d 09 | 09 69 66 20 28 70 57 45 |ngth;...|.if (pWE|
|00003b50| 2d 3e 68 41 63 74 69 6f | 6e 53 74 61 63 6b 20 21 |->hActio|nStack !|
|00003b60| 3d 20 6e 69 6c 29 0d 09 | 09 7b 0d 0d 09 09 09 2f |= nil)..|.{...../|
|00003b70| 2f 20 55 4e 44 4f 20 53 | 55 50 50 4f 52 54 20 46 |/ UNDO S|UPPORT F|
|00003b80| 4f 52 20 46 4f 52 57 41 | 52 44 20 44 45 4c 45 54 |OR FORWA|RD DELET|
|00003b90| 45 0d 0d 09 09 09 2f 2f | 20 6c 6f 63 6b 20 74 68 |E.....//| lock th|
|00003ba0| 65 20 61 63 74 69 6f 6e | 20 72 65 63 6f 72 64 0d |e action| record.|
|00003bb0| 09 09 09 73 61 76 65 41 | 63 74 69 6f 6e 4c 6f 63 |...saveA|ctionLoc|
|00003bc0| 6b 20 3d 20 5f 57 45 53 | 65 74 48 61 6e 64 6c 65 |k = _WES|etHandle|
|00003bd0| 4c 6f 63 6b 28 28 48 61 | 6e 64 6c 65 29 20 70 57 |Lock((Ha|ndle) pW|
|00003be0| 45 2d 3e 68 41 63 74 69 | 6f 6e 53 74 61 63 6b 2c |E->hActi|onStack,|
|00003bf0| 20 74 72 75 65 29 3b 0d | 09 09 09 70 41 63 74 69 | true);.|...pActi|
|00003c00| 6f 6e 20 3d 20 2a 70 57 | 45 2d 3e 68 41 63 74 69 |on = *pW|E->hActi|
|00003c10| 6f 6e 53 74 61 63 6b 3b | 0d 0d 09 09 09 2f 2f 20 |onStack;|.....// |
|00003c20| 6d 61 6b 65 20 61 20 63 | 6f 70 79 20 6f 66 20 74 |make a c|opy of t|
|00003c30| 68 65 20 63 68 61 72 61 | 63 74 65 72 20 61 62 6f |he chara|cter abo|
|00003c40| 75 74 20 74 6f 20 62 65 | 20 64 65 6c 65 74 65 64 |ut to be| deleted|
|00003c50| 0d 09 09 09 64 62 5b 30 | 5d 20 3d 20 57 45 47 65 |....db[0|] = WEGe|
|00003c60| 74 43 68 61 72 28 72 61 | 6e 67 65 53 74 61 72 74 |tChar(ra|ngeStart|
|00003c70| 2c 20 68 57 45 29 3b 0d | 09 09 09 69 66 20 28 63 |, hWE);.|...if (c|
|00003c80| 68 61 72 4c 65 6e 67 74 | 68 20 3d 3d 20 32 29 0d |harLengt|h == 2).|
|00003c90| 09 09 09 7b 0d 09 09 09 | 09 64 62 5b 31 5d 20 3d |...{....|.db[1] =|
|00003ca0| 20 57 45 47 65 74 43 68 | 61 72 28 72 61 6e 67 65 | WEGetCh|ar(range|
|00003cb0| 53 74 61 72 74 20 2b 20 | 31 2c 20 68 57 45 29 3b |Start + |1, hWE);|
|00003cc0| 0d 09 09 09 7d 0d 0d 09 | 09 09 2f 2f 20 61 70 70 |....}...|..// app|
|00003cd0| 65 6e 64 20 69 74 20 74 | 6f 20 74 68 65 20 65 6e |end it t|o the en|
|00003ce0| 64 20 6f 66 20 6f 75 72 | 20 73 61 76 65 64 20 74 |d of our| saved t|
|00003cf0| 65 78 74 20 68 61 6e 64 | 6c 65 0d 09 09 09 69 66 |ext hand|le....if|
|00003d00| 20 28 28 65 72 72 20 3d | 20 5f 57 45 53 70 6c 69 | ((err =| _WESpli|
|00003d10| 63 65 28 70 41 63 74 69 | 6f 6e 2d 3e 68 54 65 78 |ce(pActi|on->hTex|
|00003d20| 74 2c 20 26 64 62 2c 20 | 63 68 61 72 4c 65 6e 67 |t, &db, |charLeng|
|00003d30| 74 68 2c 20 2d 31 29 29 | 20 21 3d 20 6e 6f 45 72 |th, -1))| != noEr|
|00003d40| 72 29 0d 09 09 09 7b 0d | 09 09 09 09 72 65 74 75 |r)....{.|....retu|
|00003d50| 72 6e 20 65 72 72 3b 0d | 09 09 09 7d 0d 0d 09 09 |rn err;.|...}....|
|00003d60| 09 2f 2f 20 67 65 74 20 | 73 74 79 6c 65 20 72 75 |.// get |style ru|
|00003d70| 6e 20 69 6e 66 6f 20 61 | 73 73 6f 63 69 61 74 65 |n info a|ssociate|
|00003d80| 64 20 77 69 74 68 20 74 | 68 65 20 61 62 6f 75 74 |d with t|he about|
|00003d90| 2d 74 6f 2d 62 65 2d 64 | 65 6c 65 74 65 64 20 63 |-to-be-d|eleted c|
|00003da0| 68 61 72 61 63 74 65 72 | 0d 09 09 09 57 45 47 65 |haracter|....WEGe|
|00003db0| 74 52 75 6e 49 6e 66 6f | 28 72 61 6e 67 65 53 74 |tRunInfo|(rangeSt|
|00003dc0| 61 72 74 2c 20 28 57 45 | 52 75 6e 49 6e 66 6f 20 |art, (WE|RunInfo |
|00003dd0| 2a 29 26 72 75 6e 49 6e | 66 6f 2c 20 68 57 45 29 |*)&runIn|fo, hWE)|
|00003de0| 3b 0d 0d 09 09 09 2f 2f | 20 61 70 70 65 6e 64 20 |;.....//| append |
|00003df0| 61 20 6e 65 77 20 73 74 | 79 6c 65 20 65 6c 65 6d |a new st|yle elem|
|00003e00| 65 6e 74 20 74 6f 20 6f | 75 72 20 73 74 79 6c 65 |ent to o|ur style|
|00003e10| 20 73 63 72 61 70 2c 20 | 69 66 20 6e 65 63 65 73 | scrap, |if neces|
|00003e20| 73 61 72 79 0d 09 09 09 | 69 66 20 28 28 65 72 72 |sary....|if ((err|
|00003e30| 20 3d 20 5f 57 45 41 70 | 70 65 6e 64 53 74 79 6c | = _WEAp|pendStyl|
|00003e40| 65 28 70 41 63 74 69 6f | 6e 2d 3e 68 53 74 79 6c |e(pActio|n->hStyl|
|00003e50| 65 73 2c 20 26 72 75 6e | 49 6e 66 6f 2c 20 70 41 |es, &run|Info, pA|
|00003e60| 63 74 69 6f 6e 2d 3e 69 | 6e 73 52 61 6e 67 65 4c |ction->i|nsRangeL|
|00003e70| 65 6e 67 74 68 29 29 20 | 21 3d 20 6e 6f 45 72 72 |ength)) |!= noErr|
|00003e80| 29 0d 09 09 09 7b 0d 09 | 09 09 09 72 65 74 75 72 |)....{..|...retur|
|00003e90| 6e 20 65 72 72 3b 0d 09 | 09 09 7d 0d 0d 23 69 66 |n err;..|..}..#if|
|00003ea0| 20 57 41 53 54 45 5f 4f | 42 4a 45 43 54 53 0d 09 | WASTE_O|BJECTS..|
|00003eb0| 09 09 2f 2f 20 64 6f 20 | 74 68 65 20 73 61 6d 65 |..// do |the same|
|00003ec0| 20 77 69 74 68 20 6f 75 | 72 20 6f 62 6a 65 63 74 | with ou|r object|
|00003ed0| 20 73 6f 75 70 0d 09 09 | 09 69 66 20 28 28 65 72 | soup...|.if ((er|
|00003ee0| 72 20 3d 20 5f 57 45 41 | 70 70 65 6e 64 4f 62 6a |r = _WEA|ppendObj|
|00003ef0| 65 63 74 28 70 41 63 74 | 69 6f 6e 2d 3e 68 53 6f |ect(pAct|ion->hSo|
|00003f00| 75 70 2c 20 26 72 75 6e | 49 6e 66 6f 2c 20 70 41 |up, &run|Info, pA|
|00003f10| 63 74 69 6f 6e 2d 3e 69 | 6e 73 52 61 6e 67 65 4c |ction->i|nsRangeL|
|00003f20| 65 6e 67 74 68 29 29 20 | 21 3d 20 6e 6f 45 72 72 |ength)) |!= noErr|
|00003f30| 29 0d 09 09 09 7b 0d 09 | 09 09 09 72 65 74 75 72 |)....{..|...retur|
|00003f40| 6e 20 65 72 72 3b 0d 09 | 09 09 7d 0d 23 65 6e 64 |n err;..|..}.#end|
|00003f50| 69 66 0d 0d 09 09 09 2f | 2f 20 61 64 6a 75 73 74 |if...../|/ adjust|
|00003f60| 20 69 6e 74 65 72 6e 61 | 6c 20 63 6f 75 6e 74 65 | interna|l counte|
|00003f70| 72 73 0d 09 09 09 70 41 | 63 74 69 6f 6e 2d 3e 69 |rs....pA|ction->i|
|00003f80| 6e 73 52 61 6e 67 65 4c | 65 6e 67 74 68 20 2b 3d |nsRangeL|ength +=|
|00003f90| 20 63 68 61 72 4c 65 6e | 67 74 68 3b 0d 0d 09 09 | charLen|gth;....|
|00003fa0| 09 2f 2f 20 75 6e 6c 6f | 63 6b 20 74 68 65 20 61 |.// unlo|ck the a|
|00003fb0| 63 74 69 6f 6e 20 72 65 | 63 6f 72 64 0d 09 09 09 |ction re|cord....|
|00003fc0| 5f 57 45 53 65 74 48 61 | 6e 64 6c 65 4c 6f 63 6b |_WESetHa|ndleLock|
|00003fd0| 28 28 48 61 6e 64 6c 65 | 29 20 70 57 45 2d 3e 68 |((Handle|) pWE->h|
|00003fe0| 41 63 74 69 6f 6e 53 74 | 61 63 6b 2c 20 73 61 76 |ActionSt|ack, sav|
|00003ff0| 65 41 63 74 69 6f 6e 4c | 6f 63 6b 29 3b 0d 0d 09 |eActionL|ock);...|
|00004000| 09 7d 20 2f 2f 20 69 66 | 20 75 6e 64 6f 20 73 75 |.} // if| undo su|
|00004010| 70 70 6f 72 74 20 69 73 | 20 65 6e 61 62 6c 65 64 |pport is| enabled|
|00004020| 0d 09 7d 20 2f 2f 20 69 | 66 20 73 65 6c 65 63 74 |..} // i|f select|
|00004030| 69 6f 6e 20 69 73 20 65 | 6d 70 74 79 0d 0d 09 69 |ion is e|mpty...i|
|00004040| 66 20 28 28 65 72 72 20 | 3d 20 5f 57 45 44 65 6c |f ((err |= _WEDel|
|00004050| 65 74 65 52 61 6e 67 65 | 28 72 61 6e 67 65 53 74 |eteRange|(rangeSt|
|00004060| 61 72 74 2c 20 72 61 6e | 67 65 45 6e 64 2c 20 68 |art, ran|geEnd, h|
|00004070| 57 45 29 29 20 21 3d 20 | 6e 6f 45 72 72 29 0d 09 |WE)) != |noErr)..|
|00004080| 7b 0d 09 09 72 65 74 75 | 72 6e 20 65 72 72 3b 0d |{...retu|rn err;.|
|00004090| 09 7d 0d 0d 09 2f 2f 20 | 6b 65 65 70 20 74 72 61 |.}...// |keep tra|
|000040a0| 63 6b 20 6f 66 20 63 75 | 72 72 65 6e 74 20 73 65 |ck of cu|rrent se|
|000040b0| 6c 65 63 74 69 6f 6e 20 | 72 61 6e 67 65 0d 09 70 |lection |range..p|
|000040c0| 57 45 2d 3e 73 65 6c 53 | 74 61 72 74 20 3d 20 72 |WE->selS|tart = r|
|000040d0| 61 6e 67 65 53 74 61 72 | 74 3b 0d 09 70 57 45 2d |angeStar|t;..pWE-|
|000040e0| 3e 73 65 6c 45 6e 64 20 | 3d 20 72 61 6e 67 65 53 |>selEnd |= rangeS|
|000040f0| 74 61 72 74 3b 0d 0d 09 | 2f 2f 20 72 65 64 72 61 |tart;...|// redra|
|00004100| 77 20 74 68 65 20 74 65 | 78 74 0d 09 65 72 72 20 |w the te|xt..err |
|00004110| 3d 20 5f 57 45 52 65 64 | 72 61 77 28 72 61 6e 67 |= _WERed|raw(rang|
|00004120| 65 53 74 61 72 74 2c 20 | 72 61 6e 67 65 53 74 61 |eStart, |rangeSta|
|00004130| 72 74 2c 20 68 57 45 29 | 3b 0d 0d 09 72 65 74 75 |rt, hWE)|;...retu|
|00004140| 72 6e 20 65 72 72 3b 0d | 7d 0d 0d 70 61 73 63 61 |rn err;.|}..pasca|
|00004150| 6c 20 42 6f 6f 6c 65 61 | 6e 20 57 45 49 73 54 79 |l Boolea|n WEIsTy|
|00004160| 70 69 6e 67 28 57 45 48 | 61 6e 64 6c 65 20 68 57 |ping(WEH|andle hW|
|00004170| 45 29 0d 7b 0d 09 2f 2f | 20 72 65 74 75 72 6e 20 |E).{..//| return |
|00004180| 74 72 75 65 20 69 66 20 | 77 65 27 72 65 20 74 72 |true if |we're tr|
|00004190| 61 63 6b 69 6e 67 20 61 | 20 74 79 70 69 6e 67 20 |acking a| typing |
|000041a0| 73 65 71 75 65 6e 63 65 | 20 69 6e 20 74 68 65 20 |sequence| in the |
|000041b0| 73 70 65 63 69 66 69 65 | 64 20 57 45 20 69 6e 73 |specifie|d WE ins|
|000041c0| 74 61 6e 63 65 0d 0d 09 | 57 45 50 74 72 20 70 57 |tance...|WEPtr pW|
|000041d0| 45 20 3d 20 2a 68 57 45 | 3b 0d 09 57 45 41 63 74 |E = *hWE|;..WEAct|
|000041e0| 69 6f 6e 20 2a 70 41 63 | 74 69 6f 6e 3b 0d 0d 09 |ion *pAc|tion;...|
|000041f0| 2f 2f 20 74 68 65 72 65 | 20 6d 75 73 74 20 62 65 |// there| must be|
|00004200| 20 61 6e 20 75 6e 64 6f | 20 62 75 66 66 65 72 0d | an undo| buffer.|
|00004210| 09 69 66 20 28 70 57 45 | 2d 3e 68 41 63 74 69 6f |.if (pWE|->hActio|
|00004220| 6e 53 74 61 63 6b 20 3d | 3d 20 6e 69 6c 29 0d 09 |nStack =|= nil)..|
|00004230| 7b 0d 09 09 72 65 74 75 | 72 6e 20 66 61 6c 73 65 |{...retu|rn false|
|00004240| 3b 0d 09 7d 0d 0d 09 70 | 41 63 74 69 6f 6e 20 3d |;..}...p|Action =|
|00004250| 20 2a 70 57 45 2d 3e 68 | 41 63 74 69 6f 6e 53 74 | *pWE->h|ActionSt|
|00004260| 61 63 6b 3b 0d 0d 09 2f | 2f 20 74 68 65 20 61 63 |ack;.../|/ the ac|
|00004270| 74 69 6f 6e 20 6b 69 6e | 64 20 6d 75 73 74 20 62 |tion kin|d must b|
|00004280| 65 20 22 74 79 70 69 6e | 67 22 20 61 6e 64 20 74 |e "typin|g" and t|
|00004290| 68 65 20 72 65 64 6f 20 | 66 6c 61 67 20 6d 75 73 |he redo |flag mus|
|000042a0| 74 20 62 65 20 63 6c 65 | 61 72 0d 09 69 66 20 28 |t be cle|ar..if (|
|000042b0| 28 70 41 63 74 69 6f 6e | 2d 3e 61 63 74 69 6f 6e |(pAction|->action|
|000042c0| 4b 69 6e 64 20 21 3d 20 | 77 65 41 4b 54 79 70 69 |Kind != |weAKTypi|
|000042d0| 6e 67 29 20 7c 7c 20 28 | 28 70 41 63 74 69 6f 6e |ng) || (|(pAction|
|000042e0| 2d 3e 61 63 74 69 6f 6e | 46 6c 61 67 73 20 26 20 |->action|Flags & |
|000042f0| 77 65 41 46 49 73 52 65 | 64 6f 29 20 21 3d 20 30 |weAFIsRe|do) != 0|
|00004300| 29 29 0d 09 7b 0d 09 09 | 72 65 74 75 72 6e 20 66 |))..{...|return f|
|00004310| 61 6c 73 65 3b 0d 09 7d | 0d 0d 09 2f 2f 20 66 69 |alse;..}|...// fi|
|00004320| 6e 61 6c 6c 79 2c 20 74 | 68 65 20 73 65 6c 65 63 |nally, t|he selec|
|00004330| 74 69 6f 6e 20 72 61 6e | 67 65 20 6d 75 73 74 6e |tion ran|ge mustn|
|00004340| 27 74 20 68 61 76 65 20 | 6d 6f 76 65 64 20 73 69 |'t have |moved si|
|00004350| 6e 63 65 20 74 68 65 20 | 6c 61 73 74 20 57 45 4b |nce the |last WEK|
|00004360| 65 79 0d 09 69 66 20 28 | 28 70 57 45 2d 3e 73 65 |ey..if (|(pWE->se|
|00004370| 6c 53 74 61 72 74 20 21 | 3d 20 70 57 45 2d 3e 73 |lStart !|= pWE->s|
|00004380| 65 6c 45 6e 64 29 20 7c | 7c 0d 09 09 28 70 57 45 |elEnd) |||...(pWE|
|00004390| 2d 3e 73 65 6c 53 74 61 | 72 74 20 21 3d 20 70 41 |->selSta|rt != pA|
|000043a0| 63 74 69 6f 6e 2d 3e 64 | 65 6c 52 61 6e 67 65 53 |ction->d|elRangeS|
|000043b0| 74 61 72 74 20 2b 20 70 | 41 63 74 69 6f 6e 2d 3e |tart + p|Action->|
|000043c0| 64 65 6c 52 61 6e 67 65 | 4c 65 6e 67 74 68 29 29 |delRange|Length))|
|000043d0| 0d 09 7b 0d 09 09 72 65 | 74 75 72 6e 20 66 61 6c |..{...re|turn fal|
|000043e0| 73 65 3b 0d 09 7d 0d 0d | 09 72 65 74 75 72 6e 20 |se;..}..|.return |
|000043f0| 74 72 75 65 3b 0d 7d 0d | 0d 70 61 73 63 61 6c 20 |true;.}.|.pascal |
|00004400| 76 6f 69 64 20 57 45 4b | 65 79 28 53 49 6e 74 31 |void WEK|ey(SInt1|
|00004410| 36 20 6b 65 79 2c 20 45 | 76 65 6e 74 4d 6f 64 69 |6 key, E|ventModi|
|00004420| 66 69 65 72 73 20 6d 6f | 64 69 66 69 65 72 73 2c |fiers mo|difiers,|
|00004430| 20 57 45 48 61 6e 64 6c | 65 20 68 57 45 29 0d 7b | WEHandl|e hWE).{|
|00004440| 0d 09 57 45 50 74 72 20 | 70 57 45 3b 0d 09 57 45 |..WEPtr |pWE;..WE|
|00004450| 41 63 74 69 6f 6e 48 61 | 6e 64 6c 65 20 68 41 63 |ActionHa|ndle hAc|
|00004460| 74 69 6f 6e 3b 0d 09 42 | 6f 6f 6c 65 61 6e 20 73 |tion;..B|oolean s|
|00004470| 61 76 65 57 45 4c 6f 63 | 6b 3b 0d 0d 09 2f 2f 20 |aveWELoc|k;...// |
|00004480| 6c 6f 63 6b 20 74 68 65 | 20 57 45 20 72 65 63 6f |lock the| WE reco|
|00004490| 72 64 0d 09 73 61 76 65 | 57 45 4c 6f 63 6b 20 3d |rd..save|WELock =|
|000044a0| 20 5f 57 45 53 65 74 48 | 61 6e 64 6c 65 4c 6f 63 | _WESetH|andleLoc|
|000044b0| 6b 28 28 48 61 6e 64 6c | 65 29 20 68 57 45 2c 20 |k((Handl|e) hWE, |
|000044c0| 74 72 75 65 29 3b 0d 09 | 70 57 45 20 3d 20 2a 68 |true);..|pWE = *h|
|000044d0| 57 45 3b 0d 0d 09 2f 2f | 20 68 69 64 65 20 74 68 |WE;...//| hide th|
|000044e0| 65 20 63 61 72 65 74 20 | 69 66 20 69 74 27 73 20 |e caret |if it's |
|000044f0| 73 68 6f 77 69 6e 67 0d | 09 69 66 20 28 42 54 53 |showing.|.if (BTS|
|00004500| 54 28 70 57 45 2d 3e 66 | 6c 61 67 73 2c 20 77 65 |T(pWE->f|lags, we|
|00004510| 46 43 61 72 65 74 56 69 | 73 69 62 6c 65 29 29 0d |FCaretVi|sible)).|
|00004520| 09 7b 0d 09 09 5f 57 45 | 42 6c 69 6e 6b 43 61 72 |.{..._WE|BlinkCar|
|00004530| 65 74 28 68 57 45 29 3b | 0d 09 7d 0d 0d 09 2f 2f |et(hWE);|..}...//|
|00004540| 20 68 69 64 65 20 74 68 | 65 20 63 75 72 73 6f 72 | hide th|e cursor|
|00004550| 20 28 69 74 20 77 69 6c | 6c 20 73 68 6f 77 20 61 | (it wil|l show a|
|00004560| 67 61 69 6e 20 61 73 20 | 73 6f 6f 6e 20 61 73 20 |gain as |soon as |
|00004570| 69 74 27 73 20 6d 6f 76 | 65 64 29 0d 09 4f 62 73 |it's mov|ed)..Obs|
|00004580| 63 75 72 65 43 75 72 73 | 6f 72 28 29 3b 0d 0d 09 |cureCurs|or();...|
|00004590| 2f 2f 20 64 69 73 70 61 | 74 63 68 20 6f 6e 20 6b |// dispa|tch on k|
|000045a0| 65 79 20 63 6c 61 73 73 | 20 28 61 72 72 6f 77 20 |ey class| (arrow |
|000045b0| 6b 65 79 73 2c 20 70 72 | 69 6e 74 61 62 6c 65 20 |keys, pr|intable |
|000045c0| 63 68 61 72 61 63 74 65 | 72 73 2c 20 62 61 63 6b |characte|rs, back|
|000045d0| 73 70 61 63 65 29 0d 09 | 69 66 20 28 28 6b 65 79 |space)..|if ((key|
|000045e0| 20 3e 3d 20 6b 41 72 72 | 6f 77 4c 65 66 74 29 20 | >= kArr|owLeft) |
|000045f0| 26 26 20 28 6b 65 79 20 | 3c 3d 20 6b 41 72 72 6f |&& (key |<= kArro|
|00004600| 77 44 6f 77 6e 29 29 0d | 09 7b 0d 09 09 5f 57 45 |wDown)).|.{..._WE|
|00004610| 44 6f 41 72 72 6f 77 4b | 65 79 28 6b 65 79 2c 20 |DoArrowK|ey(key, |
|00004620| 6d 6f 64 69 66 69 65 72 | 73 2c 20 68 57 45 29 3b |modifier|s, hWE);|
|00004630| 0d 09 7d 0d 09 65 6c 73 | 65 0d 09 7b 0d 0d 09 09 |..}..els|e..{....|
|00004640| 2f 2f 20 6e 6f 6e 2d 61 | 72 72 6f 77 20 6b 65 79 |// non-a|rrow key|
|00004650| 73 20 6d 6f 64 69 66 79 | 20 74 68 65 20 74 65 78 |s modify| the tex|
|00004660| 74 2c 20 73 6f 20 6d 61 | 6b 65 20 73 75 72 65 20 |t, so ma|ke sure |
|00004670| 65 64 69 74 69 6e 67 20 | 69 73 20 61 6c 6c 6f 77 |editing |is allow|
|00004680| 65 64 0d 09 09 69 66 20 | 28 21 42 54 53 54 28 70 |ed...if |(!BTST(p|
|00004690| 57 45 2d 3e 66 65 61 74 | 75 72 65 73 2c 20 77 65 |WE->feat|ures, we|
|000046a0| 46 52 65 61 64 4f 6e 6c | 79 29 29 0d 09 09 7b 0d |FReadOnl|y))...{.|
|000046b0| 09 09 09 2f 2f 20 61 72 | 65 20 77 65 20 74 72 61 |...// ar|e we tra|
|000046c0| 63 6b 69 6e 67 20 61 20 | 74 79 70 69 6e 67 20 73 |cking a |typing s|
|000046d0| 65 71 75 65 6e 63 65 3f | 0d 09 09 09 69 66 20 28 |equence?|....if (|
|000046e0| 21 57 45 49 73 54 79 70 | 69 6e 67 28 68 57 45 29 |!WEIsTyp|ing(hWE)|
|000046f0| 29 0d 09 09 09 7b 0d 09 | 09 09 09 2f 2f 20 6e 6f |)....{..|...// no|
|00004700| 70 65 3b 20 20 73 74 61 | 72 74 20 61 20 6e 65 77 |pe; sta|rt a new|
|00004710| 20 6f 6e 65 0d 09 09 09 | 09 2f 2f 20 69 6e 63 72 | one....|.// incr|
|00004720| 65 6d 65 6e 74 20 6d 6f | 64 69 66 69 63 61 74 69 |ement mo|dificati|
|00004730| 6f 6e 20 63 6f 75 6e 74 | 0d 09 09 09 09 70 57 45 |on count|.....pWE|
|00004740| 2d 3e 6d 6f 64 43 6f 75 | 6e 74 2b 2b 3b 0d 0d 09 |->modCou|nt++;...|
|00004750| 09 09 09 2f 2f 20 69 66 | 20 75 6e 64 6f 20 73 75 |...// if| undo su|
|00004760| 70 70 6f 72 74 20 69 73 | 20 65 6e 61 62 6c 65 64 |pport is| enabled|
|00004770| 2c 20 63 72 65 61 74 65 | 20 61 20 6e 65 77 20 61 |, create| a new a|
|00004780| 63 74 69 6f 6e 20 74 6f | 20 6b 65 65 70 20 74 72 |ction to| keep tr|
|00004790| 61 63 6b 20 6f 66 20 74 | 79 70 69 6e 67 0d 09 09 |ack of t|yping...|
|000047a0| 09 09 69 66 20 28 42 54 | 53 54 28 70 57 45 2d 3e |..if (BT|ST(pWE->|
|000047b0| 66 65 61 74 75 72 65 73 | 2c 20 77 65 46 55 6e 64 |features|, weFUnd|
|000047c0| 6f 29 29 0d 09 09 09 09 | 7b 0d 09 09 09 09 09 57 |o)).....|{......W|
|000047d0| 45 43 6c 65 61 72 55 6e | 64 6f 28 68 57 45 29 3b |EClearUn|do(hWE);|
|000047e0| 0d 09 09 09 09 09 69 66 | 20 28 5f 57 45 4e 65 77 |......if| (_WENew|
|000047f0| 41 63 74 69 6f 6e 28 70 | 57 45 2d 3e 73 65 6c 53 |Action(p|WE->selS|
|00004800| 74 61 72 74 2c 20 70 57 | 45 2d 3e 73 65 6c 45 6e |tart, pW|E->selEn|
|00004810| 64 2c 20 30 2c 20 77 65 | 41 4b 54 79 70 69 6e 67 |d, 0, we|AKTyping|
|00004820| 2c 20 30 2c 20 68 57 45 | 2c 20 26 68 41 63 74 69 |, 0, hWE|, &hActi|
|00004830| 6f 6e 29 20 3d 3d 20 6e | 6f 45 72 72 29 0d 09 09 |on) == n|oErr)...|
|00004840| 09 09 09 7b 0d 09 09 09 | 09 09 09 5f 57 45 50 75 |...{....|..._WEPu|
|00004850| 73 68 41 63 74 69 6f 6e | 28 68 41 63 74 69 6f 6e |shAction|(hAction|
|00004860| 29 3b 0d 09 09 09 09 09 | 7d 0d 09 09 09 09 7d 0d |);......|}.....}.|
|00004870| 09 09 09 7d 20 2f 2f 20 | 69 66 20 57 45 49 73 54 |...} // |if WEIsT|
|00004880| 79 70 69 6e 67 0d 0d 09 | 09 09 69 66 20 28 6b 65 |yping...|..if (ke|
|00004890| 79 20 3d 3d 20 6b 42 61 | 63 6b 73 70 61 63 65 29 |y == kBa|ckspace)|
|000048a0| 0d 09 09 09 7b 0d 09 09 | 09 09 5f 57 45 42 61 63 |....{...|.._WEBac|
|000048b0| 6b 73 70 61 63 65 28 68 | 57 45 29 3b 0d 09 09 09 |kspace(h|WE);....|
|000048c0| 7d 0d 09 09 09 65 6c 73 | 65 20 69 66 20 28 6b 65 |}....els|e if (ke|
|000048d0| 79 20 3d 3d 20 6b 46 6f | 72 77 61 72 64 44 65 6c |y == kFo|rwardDel|
|000048e0| 65 74 65 29 0d 09 09 09 | 7b 0d 09 09 09 09 5f 57 |ete)....|{....._W|
|000048f0| 45 46 6f 72 77 61 72 64 | 44 65 6c 65 74 65 28 68 |EForward|Delete(h|
|00004900| 57 45 29 3b 0d 09 09 09 | 7d 0d 09 09 09 65 6c 73 |WE);....|}....els|
|00004910| 65 0d 09 09 09 7b 0d 09 | 09 09 09 5f 57 45 54 79 |e....{..|..._WETy|
|00004920| 70 65 43 68 61 72 28 6b | 65 79 2c 20 68 57 45 29 |peChar(k|ey, hWE)|
|00004930| 3b 0d 09 09 09 7d 0d 09 | 09 7d 20 2f 2f 20 69 66 |;....}..|.} // if|
|00004940| 20 6e 6f 74 20 72 65 61 | 64 2d 6f 6e 6c 79 0d 09 | not rea|d-only..|
|00004950| 7d 0d 0d 09 2f 2f 20 75 | 6e 6c 6f 63 6b 20 74 68 |}...// u|nlock th|
|00004960| 65 20 57 45 20 72 65 63 | 6f 72 64 0d 09 5f 57 45 |e WE rec|ord.._WE|
|00004970| 53 65 74 48 61 6e 64 6c | 65 4c 6f 63 6b 28 28 48 |SetHandl|eLock((H|
|00004980| 61 6e 64 6c 65 29 20 68 | 57 45 2c 20 73 61 76 65 |andle) h|WE, save|
|00004990| 57 45 4c 6f 63 6b 29 3b | 0d 7d 0d 0d 70 61 73 63 |WELock);|.}..pasc|
|000049a0| 61 6c 20 4f 53 45 72 72 | 20 57 45 49 6e 73 65 72 |al OSErr| WEInser|
|000049b0| 74 28 63 6f 6e 73 74 20 | 76 6f 69 64 20 2a 74 65 |t(const |void *te|
|000049c0| 78 74 50 74 72 2c 20 53 | 49 6e 74 33 32 20 74 65 |xtPtr, S|Int32 te|
|000049d0| 78 74 4c 65 6e 67 74 68 | 2c 20 53 74 53 63 72 70 |xtLength|, StScrp|
|000049e0| 48 61 6e 64 6c 65 20 68 | 53 74 79 6c 65 73 2c 20 |Handle h|Styles, |
|000049f0| 57 45 53 6f 75 70 48 61 | 6e 64 6c 65 20 68 53 6f |WESoupHa|ndle hSo|
|00004a00| 75 70 2c 20 57 45 52 65 | 66 65 72 65 6e 63 65 20 |up, WERe|ference |
|00004a10| 68 57 45 29 0d 7b 0d 23 | 69 66 20 21 57 41 53 54 |hWE).{.#|if !WAST|
|00004a20| 45 5f 4f 42 4a 45 43 54 | 53 0d 23 70 72 61 67 6d |E_OBJECT|S.#pragm|
|00004a30| 61 20 75 6e 75 73 65 64 | 28 68 53 6f 75 70 29 0d |a unused|(hSoup).|
|00004a40| 23 65 6e 64 69 66 0d 09 | 57 45 50 74 72 20 70 57 |#endif..|WEPtr pW|
|00004a50| 45 3b 0d 09 53 49 6e 74 | 33 32 20 6f 66 66 73 65 |E;..SInt|32 offse|
|00004a60| 74 2c 20 65 6e 64 4f 66 | 66 73 65 74 3b 0d 09 57 |t, endOf|fset;..W|
|00004a70| 45 41 63 74 69 6f 6e 48 | 61 6e 64 6c 65 20 68 41 |EActionH|andle hA|
|00004a80| 63 74 69 6f 6e 3b 0d 09 | 53 49 6e 74 31 36 20 69 |ction;..|SInt16 i|
|00004a90| 6e 74 50 61 73 74 65 41 | 63 74 69 6f 6e 3b 0d 09 |ntPasteA|ction;..|
|00004aa0| 42 6f 6f 6c 65 61 6e 20 | 73 61 76 65 57 45 4c 6f |Boolean |saveWELo|
|00004ab0| 63 6b 3b 0d 09 63 68 61 | 72 20 73 70 61 63 65 20 |ck;..cha|r space |
|00004ac0| 3d 20 6b 53 70 61 63 65 | 3b 0d 09 4f 53 45 72 72 |= kSpace|;..OSErr|
|00004ad0| 20 65 72 72 3b 0d 0d 09 | 2f 2f 20 6c 6f 63 6b 20 | err;...|// lock |
|00004ae0| 74 68 65 20 57 45 20 72 | 65 63 6f 72 64 0d 09 73 |the WE r|ecord..s|
|00004af0| 61 76 65 57 45 4c 6f 63 | 6b 20 3d 20 5f 57 45 53 |aveWELoc|k = _WES|
|00004b00| 65 74 48 61 6e 64 6c 65 | 4c 6f 63 6b 28 28 48 61 |etHandle|Lock((Ha|
|00004b10| 6e 64 6c 65 29 20 68 57 | 45 2c 20 74 72 75 65 29 |ndle) hW|E, true)|
|00004b20| 3b 0d 09 70 57 45 20 3d | 20 2a 68 57 45 3b 0d 09 |;..pWE =| *hWE;..|
|00004b30| 6f 66 66 73 65 74 20 3d | 20 70 57 45 2d 3e 73 65 |offset =| pWE->se|
|00004b40| 6c 53 74 61 72 74 3b 0d | 0d 09 2f 2f 20 72 65 74 |lStart;.|..// ret|
|00004b50| 75 72 6e 20 61 6e 20 65 | 72 72 6f 72 20 63 6f 64 |urn an e|rror cod|
|00004b60| 65 20 69 66 20 74 68 69 | 73 20 69 6e 73 74 61 6e |e if thi|s instan|
|00004b70| 63 65 20 69 73 20 72 65 | 61 64 2d 6f 6e 6c 79 0d |ce is re|ad-only.|
|00004b80| 09 65 72 72 20 3d 20 77 | 65 52 65 61 64 4f 6e 6c |.err = w|eReadOnl|
|00004b90| 79 45 72 72 3b 0d 09 69 | 66 20 28 42 54 53 54 28 |yErr;..i|f (BTST(|
|00004ba0| 70 57 45 2d 3e 66 65 61 | 74 75 72 65 73 2c 20 77 |pWE->fea|tures, w|
|00004bb0| 65 46 52 65 61 64 4f 6e | 6c 79 29 29 0d 09 7b 0d |eFReadOn|ly))..{.|
|00004bc0| 09 09 67 6f 74 6f 20 63 | 6c 65 61 6e 75 70 3b 0d |..goto c|leanup;.|
|00004bd0| 09 7d 0d 0d 09 2f 2f 20 | 73 74 6f 70 20 61 6e 79 |.}...// |stop any|
|00004be0| 20 6f 6e 67 6f 69 6e 67 | 20 69 6e 6c 69 6e 65 20 | ongoing| inline |
|00004bf0| 69 6e 70 75 74 20 73 65 | 73 73 69 6f 6e 0d 09 57 |input se|ssion..W|
|00004c00| 45 53 74 6f 70 49 6e 6c | 69 6e 65 53 65 73 73 69 |EStopInl|ineSessi|
|00004c10| 6f 6e 28 68 57 45 29 3b | 0d 0d 09 2f 2f 20 69 6e |on(hWE);|...// in|
|00004c20| 63 72 65 6d 65 6e 74 20 | 6d 6f 64 69 66 69 63 61 |crement |modifica|
|00004c30| 74 69 6f 6e 20 63 6f 75 | 6e 74 0d 09 70 57 45 2d |tion cou|nt..pWE-|
|00004c40| 3e 6d 6f 64 43 6f 75 6e | 74 2b 2b 3b 0d 0d 09 2f |>modCoun|t++;.../|
|00004c50| 2f 20 69 66 20 75 6e 64 | 6f 20 73 75 70 70 6f 72 |/ if und|o suppor|
|00004c60| 74 20 69 73 20 65 6e 61 | 62 6c 65 64 2c 20 73 61 |t is ena|bled, sa|
|00004c70| 76 65 20 63 75 72 72 65 | 6e 74 20 73 65 6c 65 63 |ve curre|nt selec|
|00004c80| 74 69 6f 6e 20 72 61 6e | 67 65 0d 09 69 66 20 28 |tion ran|ge..if (|
|00004c90| 42 54 53 54 28 70 57 45 | 2d 3e 66 65 61 74 75 72 |BTST(pWE|->featur|
|00004ca0| 65 73 2c 20 77 65 46 55 | 6e 64 6f 29 29 0d 09 7b |es, weFU|ndo))..{|
|00004cb0| 0d 09 09 57 45 43 6c 65 | 61 72 55 6e 64 6f 28 68 |...WECle|arUndo(h|
|00004cc0| 57 45 29 3b 0d 09 09 69 | 66 20 28 5f 57 45 4e 65 |WE);...i|f (_WENe|
|00004cd0| 77 41 63 74 69 6f 6e 28 | 6f 66 66 73 65 74 2c 20 |wAction(|offset, |
|00004ce0| 70 57 45 2d 3e 73 65 6c | 45 6e 64 2c 20 74 65 78 |pWE->sel|End, tex|
|00004cf0| 74 4c 65 6e 67 74 68 2c | 20 77 65 41 4b 55 6e 73 |tLength,| weAKUns|
|00004d00| 70 65 63 69 66 69 65 64 | 2c 20 30 2c 20 68 57 45 |pecified|, 0, hWE|
|00004d10| 2c 20 26 68 41 63 74 69 | 6f 6e 29 20 3d 3d 20 6e |, &hActi|on) == n|
|00004d20| 6f 45 72 72 29 0d 09 09 | 7b 0d 09 09 09 5f 57 45 |oErr)...|{...._WE|
|00004d30| 50 75 73 68 41 63 74 69 | 6f 6e 28 68 41 63 74 69 |PushActi|on(hActi|
|00004d40| 6f 6e 29 3b 0d 09 09 7d | 0d 09 7d 0d 0d 09 2f 2f |on);...}|..}...//|
|00004d50| 20 64 65 6c 65 74 65 20 | 63 75 72 72 65 6e 74 20 | delete |current |
|00004d60| 73 65 6c 65 63 74 69 6f | 6e 0d 09 69 66 20 28 28 |selectio|n..if ((|
|00004d70| 65 72 72 20 3d 20 5f 57 | 45 44 65 6c 65 74 65 52 |err = _W|EDeleteR|
|00004d80| 61 6e 67 65 28 6f 66 66 | 73 65 74 2c 20 70 57 45 |ange(off|set, pWE|
|00004d90| 2d 3e 73 65 6c 45 6e 64 | 2c 20 68 57 45 29 29 20 |->selEnd|, hWE)) |
|00004da0| 21 3d 20 6e 6f 45 72 72 | 29 0d 09 7b 0d 09 09 67 |!= noErr|)..{...g|
|00004db0| 6f 74 6f 20 63 6c 65 61 | 6e 75 70 3b 0d 09 7d 0d |oto clea|nup;..}.|
|00004dc0| 0d 09 2f 2f 20 69 6e 73 | 65 72 74 20 74 68 65 20 |..// ins|ert the |
|00004dd0| 6e 65 77 20 74 65 78 74 | 20 61 74 20 74 68 65 20 |new text| at the |
|00004de0| 69 6e 73 65 72 74 69 6f | 6e 20 70 6f 69 6e 74 0d |insertio|n point.|
|00004df0| 09 69 66 20 28 28 65 72 | 72 20 3d 20 5f 57 45 49 |.if ((er|r = _WEI|
|00004e00| 6e 73 65 72 74 54 65 78 | 74 28 6f 66 66 73 65 74 |nsertTex|t(offset|
|00004e10| 2c 20 74 65 78 74 50 74 | 72 2c 20 74 65 78 74 4c |, textPt|r, textL|
|00004e20| 65 6e 67 74 68 2c 20 68 | 57 45 29 29 20 21 3d 20 |ength, h|WE)) != |
|00004e30| 6e 6f 45 72 72 29 0d 09 | 7b 0d 09 09 67 6f 74 6f |noErr)..|{...goto|
|00004e40| 20 63 6c 65 61 6e 75 70 | 3b 0d 09 7d 0d 09 65 6e | cleanup|;..}..en|
|00004e50| 64 4f 66 66 73 65 74 20 | 3d 20 6f 66 66 73 65 74 |dOffset |= offset|
|00004e60| 20 2b 20 74 65 78 74 4c | 65 6e 67 74 68 3b 0d 0d | + textL|ength;..|
|00004e70| 09 69 66 20 28 68 53 74 | 79 6c 65 73 20 21 3d 20 |.if (hSt|yles != |
|00004e80| 6e 69 6c 29 0d 09 7b 0d | 0d 09 09 2f 2f 20 69 66 |nil)..{.|...// if|
|00004e90| 20 61 20 73 74 79 6c 65 | 20 73 63 72 61 70 20 77 | a style| scrap w|
|00004ea0| 61 73 20 73 75 70 70 6c | 69 65 64 2c 20 61 70 70 |as suppl|ied, app|
|00004eb0| 6c 79 20 69 74 20 74 6f | 20 74 68 65 20 6e 65 77 |ly it to| the new|
|00004ec0| 6c 79 20 69 6e 73 65 72 | 74 65 64 20 74 65 78 74 |ly inser|ted text|
|00004ed0| 0d 09 09 69 66 20 28 28 | 65 72 72 20 3d 20 5f 57 |...if ((|err = _W|
|00004ee0| 45 41 70 70 6c 79 53 74 | 79 6c 65 53 63 72 61 70 |EApplySt|yleScrap|
|00004ef0| 28 6f 66 66 73 65 74 2c | 20 65 6e 64 4f 66 66 73 |(offset,| endOffs|
|00004f00| 65 74 2c 20 68 53 74 79 | 6c 65 73 2c 20 68 57 45 |et, hSty|les, hWE|
|00004f10| 29 29 20 21 3d 20 6e 6f | 45 72 72 29 0d 09 09 7b |)) != no|Err)...{|
|00004f20| 0d 09 09 09 67 6f 74 6f | 20 63 6c 65 61 6e 75 70 |....goto| cleanup|
|00004f30| 3b 0d 09 09 7d 0d 09 7d | 0d 0d 23 69 66 20 57 41 |;...}..}|..#if WA|
|00004f40| 53 54 45 5f 4f 42 4a 45 | 43 54 53 0d 09 69 66 20 |STE_OBJE|CTS..if |
|00004f50| 28 68 53 6f 75 70 20 21 | 3d 20 6e 69 6c 29 0d 09 |(hSoup !|= nil)..|
|00004f60| 7b 0d 09 09 2f 2f 20 69 | 66 20 61 6e 20 6f 62 6a |{...// i|f an obj|
|00004f70| 65 63 74 20 73 6f 75 70 | 20 77 61 73 20 73 75 70 |ect soup| was sup|
|00004f80| 70 6c 69 65 64 2c 20 61 | 70 70 6c 79 20 69 74 20 |plied, a|pply it |
|00004f90| 74 6f 20 74 68 65 20 6e | 65 77 6c 79 20 69 6e 73 |to the n|ewly ins|
|00004fa0| 65 72 74 65 64 20 74 65 | 78 74 0d 09 09 69 66 20 |erted te|xt...if |
|00004fb0| 28 28 65 72 72 20 3d 20 | 5f 57 45 41 70 70 6c 79 |((err = |_WEApply|
|00004fc0| 53 6f 75 70 28 6f 66 66 | 73 65 74 2c 20 68 53 6f |Soup(off|set, hSo|
|00004fd0| 75 70 2c 20 68 57 45 29 | 29 20 21 3d 20 6e 6f 45 |up, hWE)|) != noE|
|00004fe0| 72 72 29 0d 09 09 7b 0d | 09 09 09 67 6f 74 6f 20 |rr)...{.|...goto |
|00004ff0| 63 6c 65 61 6e 75 70 3b | 0d 09 09 7d 0d 09 7d 0d |cleanup;|...}..}.|
|00005000| 23 65 6e 64 69 66 0d 0d | 09 2f 2f 20 64 65 74 65 |#endif..|.// dete|
|00005010| 72 6d 69 6e 65 20 77 68 | 65 74 68 65 72 20 61 6e |rmine wh|ether an|
|00005020| 20 65 78 74 72 61 20 73 | 70 61 63 65 20 73 68 6f | extra s|pace sho|
|00005030| 75 6c 64 20 62 65 20 61 | 64 64 65 64 20 62 65 66 |uld be a|dded bef|
|00005040| 6f 72 65 20 6f 72 20 61 | 66 74 65 72 20 74 68 65 |ore or a|fter the|
|00005050| 20 69 6e 73 65 72 74 65 | 64 20 74 65 78 74 0d 09 | inserte|d text..|
|00005060| 69 6e 74 50 61 73 74 65 | 41 63 74 69 6f 6e 20 3d |intPaste|Action =|
|00005070| 20 5f 57 45 49 6e 74 65 | 6c 6c 69 67 65 6e 74 50 | _WEInte|lligentP|
|00005080| 61 73 74 65 28 6f 66 66 | 73 65 74 2c 20 65 6e 64 |aste(off|set, end|
|00005090| 4f 66 66 73 65 74 2c 20 | 68 57 45 29 3b 0d 0d 09 |Offset, |hWE);...|
|000050a0| 2f 2f 20 61 64 64 20 74 | 68 65 20 65 78 74 72 61 |// add t|he extra|
|000050b0| 20 73 70 61 63 65 2c 20 | 69 66 20 6e 65 63 65 73 | space, |if neces|
|000050c0| 73 61 72 79 0d 09 69 66 | 20 28 69 6e 74 50 61 73 |sary..if| (intPas|
|000050d0| 74 65 41 63 74 69 6f 6e | 20 21 3d 20 77 65 44 6f |teAction| != weDo|
|000050e0| 6e 74 41 64 64 53 70 61 | 63 65 73 29 0d 09 7b 0d |ntAddSpa|ces)..{.|
|000050f0| 09 09 69 66 20 28 69 6e | 74 50 61 73 74 65 41 63 |..if (in|tPasteAc|
|00005100| 74 69 6f 6e 20 3d 3d 20 | 77 65 41 64 64 53 70 61 |tion == |weAddSpa|
|00005110| 63 65 4f 6e 4c 65 66 74 | 53 69 64 65 29 0d 09 09 |ceOnLeft|Side)...|
|00005120| 7b 0d 09 09 09 65 72 72 | 20 3d 20 5f 57 45 49 6e |{....err| = _WEIn|
|00005130| 73 65 72 74 54 65 78 74 | 28 6f 66 66 73 65 74 2c |sertText|(offset,|
|00005140| 20 26 73 70 61 63 65 2c | 20 73 69 7a 65 6f 66 28 | &space,| sizeof(|
|00005150| 73 70 61 63 65 29 2c 20 | 68 57 45 29 3b 0d 09 09 |space), |hWE);...|
|00005160| 7d 0d 09 09 65 6c 73 65 | 0d 09 09 7b 0d 09 09 09 |}...else|...{....|
|00005170| 65 72 72 20 3d 20 5f 57 | 45 49 6e 73 65 72 74 54 |err = _W|EInsertT|
|00005180| 65 78 74 28 65 6e 64 4f | 66 66 73 65 74 2c 20 26 |ext(endO|ffset, &|
|00005190| 73 70 61 63 65 2c 20 73 | 69 7a 65 6f 66 28 73 70 |space, s|izeof(sp|
|000051a0| 61 63 65 29 2c 20 68 57 | 45 29 3b 0d 09 09 7d 0d |ace), hW|E);...}.|
|000051b0| 09 09 69 66 20 28 65 72 | 72 20 21 3d 20 6e 6f 45 |..if (er|r != noE|
|000051c0| 72 72 29 0d 09 09 7b 0d | 09 09 09 67 6f 74 6f 20 |rr)...{.|...goto |
|000051d0| 63 6c 65 61 6e 75 70 3b | 0d 09 09 7d 0d 09 09 65 |cleanup;|...}...e|
|000051e0| 6e 64 4f 66 66 73 65 74 | 2b 2b 3b 0d 0d 09 09 2f |ndOffset|++;..../|
|000051f0| 2f 20 61 64 6a 75 73 74 | 20 75 6e 64 6f 20 62 75 |/ adjust| undo bu|
|00005200| 66 66 65 72 20 28 69 66 | 20 61 6e 79 29 20 66 6f |ffer (if| any) fo|
|00005210| 72 20 74 68 65 20 65 78 | 74 72 61 20 73 70 61 63 |r the ex|tra spac|
|00005220| 65 0d 09 09 5f 57 45 41 | 64 6a 75 73 74 55 6e 64 |e..._WEA|djustUnd|
|00005230| 6f 52 61 6e 67 65 28 73 | 69 7a 65 6f 66 28 73 70 |oRange(s|izeof(sp|
|00005240| 61 63 65 29 2c 20 68 57 | 45 29 3b 0d 09 7d 0d 0d |ace), hW|E);..}..|
|00005250| 09 2f 2f 20 69 6e 76 61 | 6c 69 64 20 74 68 65 20 |.// inva|lid the |
|00005260| 6e 75 6c 6c 20 73 74 79 | 6c 65 0d 09 42 43 4c 52 |null sty|le..BCLR|
|00005270| 28 70 57 45 2d 3e 66 6c | 61 67 73 2c 20 77 65 46 |(pWE->fl|ags, weF|
|00005280| 55 73 65 4e 75 6c 6c 53 | 74 79 6c 65 29 3b 0d 0d |UseNullS|tyle);..|
|00005290| 09 2f 2f 20 6d 6f 76 65 | 20 74 68 65 20 69 6e 73 |.// move| the ins|
|000052a0| 65 72 74 69 6f 6e 20 70 | 6f 69 6e 74 20 61 74 20 |ertion p|oint at |
|000052b0| 74 68 65 20 65 6e 64 20 | 6f 66 20 74 68 65 20 69 |the end |of the i|
|000052c0| 6e 73 65 72 74 65 64 20 | 74 65 78 74 0d 09 70 57 |nserted |text..pW|
|000052d0| 45 2d 3e 73 65 6c 53 74 | 61 72 74 20 3d 20 65 6e |E->selSt|art = en|
|000052e0| 64 4f 66 66 73 65 74 3b | 0d 09 70 57 45 2d 3e 73 |dOffset;|..pWE->s|
|000052f0| 65 6c 45 6e 64 20 3d 20 | 65 6e 64 4f 66 66 73 65 |elEnd = |endOffse|
|00005300| 74 3b 0d 0d 09 2f 2f 20 | 72 65 64 72 61 77 20 74 |t;...// |redraw t|
|00005310| 68 65 20 74 65 78 74 0d | 09 69 66 20 28 28 65 72 |he text.|.if ((er|
|00005320| 72 20 3d 20 5f 57 45 52 | 65 64 72 61 77 28 6f 66 |r = _WER|edraw(of|
|00005330| 66 73 65 74 2c 20 65 6e | 64 4f 66 66 73 65 74 2c |fset, en|dOffset,|
|00005340| 20 68 57 45 29 29 20 21 | 3d 20 6e 6f 45 72 72 29 | hWE)) !|= noErr)|
|00005350| 0d 09 7b 0d 09 09 67 6f | 74 6f 20 63 6c 65 61 6e |..{...go|to clean|
|00005360| 75 70 3b 0d 09 7d 0d 0d | 09 2f 2f 20 63 6c 65 61 |up;..}..|.// clea|
|00005370| 72 20 72 65 73 75 6c 74 | 20 63 6f 64 65 0d 09 65 |r result| code..e|
|00005380| 72 72 20 3d 20 6e 6f 45 | 72 72 3b 0d 0d 63 6c 65 |rr = noE|rr;..cle|
|00005390| 61 6e 75 70 3a 0d 09 2f | 2f 20 75 6e 6c 6f 63 6b |anup:../|/ unlock|
|000053a0| 20 74 68 65 20 57 45 20 | 72 65 63 6f 72 64 0d 09 | the WE |record..|
|000053b0| 5f 57 45 53 65 74 48 61 | 6e 64 6c 65 4c 6f 63 6b |_WESetHa|ndleLock|
|000053c0| 28 28 48 61 6e 64 6c 65 | 29 20 68 57 45 2c 20 73 |((Handle|) hWE, s|
|000053d0| 61 76 65 57 45 4c 6f 63 | 6b 29 3b 0d 0d 09 2f 2f |aveWELoc|k);...//|
|000053e0| 20 72 65 74 75 72 6e 20 | 72 65 73 75 6c 74 20 63 | return |result c|
|000053f0| 6f 64 65 0d 09 72 65 74 | 75 72 6e 20 65 72 72 3b |ode..ret|urn err;|
|00005400| 0d 7d 0d 0d 23 69 66 20 | 57 41 53 54 45 5f 4f 42 |.}..#if |WASTE_OB|
|00005410| 4a 45 43 54 53 0d 0d 70 | 61 73 63 61 6c 20 4f 53 |JECTS..p|ascal OS|
|00005420| 45 72 72 20 57 45 49 6e | 73 65 72 74 4f 62 6a 65 |Err WEIn|sertObje|
|00005430| 63 74 28 46 6c 61 76 6f | 72 54 79 70 65 20 6f 62 |ct(Flavo|rType ob|
|00005440| 6a 65 63 74 54 79 70 65 | 2c 20 48 61 6e 64 6c 65 |jectType|, Handle|
|00005450| 20 6f 62 6a 65 63 74 44 | 61 74 61 48 61 6e 64 6c | objectD|ataHandl|
|00005460| 65 2c 20 50 6f 69 6e 74 | 20 6f 62 6a 65 63 74 53 |e, Point| objectS|
|00005470| 69 7a 65 2c 20 57 45 48 | 61 6e 64 6c 65 20 68 57 |ize, WEH|andle hW|
|00005480| 45 29 0d 7b 0d 09 57 45 | 50 74 72 20 70 57 45 3b |E).{..WE|Ptr pWE;|
|00005490| 0d 09 57 45 41 63 74 69 | 6f 6e 48 61 6e 64 6c 65 |..WEActi|onHandle|
|000054a0| 20 68 41 63 74 69 6f 6e | 3b 0d 09 53 49 6e 74 33 | hAction|;..SInt3|
|000054b0| 32 20 6f 66 66 73 65 74 | 2c 20 65 6e 64 4f 66 66 |2 offset|, endOff|
|000054c0| 73 65 74 3b 0d 09 57 45 | 54 65 78 74 53 74 79 6c |set;..WE|TextStyl|
|000054d0| 65 20 74 73 3b 0d 09 42 | 6f 6f 6c 65 61 6e 20 73 |e ts;..B|oolean s|
|000054e0| 61 76 65 57 45 4c 6f 63 | 6b 3b 0d 09 63 68 61 72 |aveWELoc|k;..char|
|000054f0| 20 6d 61 72 6b 65 72 20 | 3d 20 6b 4f 62 6a 65 63 | marker |= kObjec|
|00005500| 74 4d 61 72 6b 65 72 3b | 0d 09 4f 53 45 72 72 20 |tMarker;|..OSErr |
|00005510| 65 72 72 3b 0d 0d 09 42 | 4c 4f 43 4b 5f 43 4c 52 |err;...B|LOCK_CLR|
|00005520| 28 74 73 29 3b 0d 0d 09 | 2f 2f 20 6c 6f 63 6b 20 |(ts);...|// lock |
|00005530| 74 68 65 20 57 45 20 72 | 65 63 6f 72 64 0d 09 73 |the WE r|ecord..s|
|00005540| 61 76 65 57 45 4c 6f 63 | 6b 20 3d 20 5f 57 45 53 |aveWELoc|k = _WES|
|00005550| 65 74 48 61 6e 64 6c 65 | 4c 6f 63 6b 28 28 48 61 |etHandle|Lock((Ha|
|00005560| 6e 64 6c 65 29 20 68 57 | 45 2c 20 74 72 75 65 29 |ndle) hW|E, true)|
|00005570| 3b 0d 09 70 57 45 20 3d | 20 2a 68 57 45 3b 0d 09 |;..pWE =| *hWE;..|
|00005580| 6f 66 66 73 65 74 20 3d | 20 70 57 45 2d 3e 73 65 |offset =| pWE->se|
|00005590| 6c 53 74 61 72 74 3b 0d | 0d 09 2f 2f 20 72 65 74 |lStart;.|..// ret|
|000055a0| 75 72 6e 20 61 6e 20 65 | 72 72 6f 72 20 63 6f 64 |urn an e|rror cod|
|000055b0| 65 20 69 66 20 74 68 69 | 73 20 69 6e 73 74 61 6e |e if thi|s instan|
|000055c0| 63 65 20 69 73 20 72 65 | 61 64 2d 6f 6e 6c 79 0d |ce is re|ad-only.|
|000055d0| 09 65 72 72 20 3d 20 77 | 65 52 65 61 64 4f 6e 6c |.err = w|eReadOnl|
|000055e0| 79 45 72 72 3b 0d 09 69 | 66 20 28 42 54 53 54 28 |yErr;..i|f (BTST(|
|000055f0| 70 57 45 2d 3e 66 65 61 | 74 75 72 65 73 2c 20 77 |pWE->fea|tures, w|
|00005600| 65 46 52 65 61 64 4f 6e | 6c 79 29 29 0d 09 7b 0d |eFReadOn|ly))..{.|
|00005610| 09 09 67 6f 74 6f 20 63 | 6c 65 61 6e 75 70 3b 0d |..goto c|leanup;.|
|00005620| 09 7d 0d 0d 09 2f 2f 20 | 73 74 6f 70 20 61 6e 79 |.}...// |stop any|
|00005630| 20 6f 6e 67 6f 69 6e 67 | 20 69 6e 6c 69 6e 65 20 | ongoing| inline |
|00005640| 69 6e 70 75 74 20 73 65 | 73 73 69 6f 6e 0d 09 57 |input se|ssion..W|
|00005650| 45 53 74 6f 70 49 6e 6c | 69 6e 65 53 65 73 73 69 |EStopInl|ineSessi|
|00005660| 6f 6e 28 68 57 45 29 3b | 0d 0d 09 2f 2f 20 63 61 |on(hWE);|...// ca|
|00005670| 6c 6c 20 74 68 65 20 27 | 6e 65 77 27 20 68 61 6e |ll the '|new' han|
|00005680| 64 6c 65 72 20 74 6f 20 | 69 6e 69 74 69 61 6c 69 |dler to |initiali|
|00005690| 7a 65 20 70 72 69 76 61 | 74 65 20 6f 62 6a 65 63 |ze priva|te objec|
|000056a0| 74 20 73 74 6f 72 61 67 | 65 20 28 69 66 20 61 6e |t storag|e (if an|
|000056b0| 79 29 0d 09 2f 2f 20 61 | 6e 64 20 74 6f 20 63 61 |y)..// a|nd to ca|
|000056c0| 6c 63 75 6c 61 74 65 20 | 74 68 65 20 64 65 66 61 |lculate |the defa|
|000056d0| 75 6c 74 20 73 69 7a 65 | 20 66 6f 72 20 74 68 69 |ult size| for thi|
|000056e0| 73 20 6f 62 6a 65 63 74 | 0d 0d 09 69 66 20 28 28 |s object|...if ((|
|000056f0| 65 72 72 20 3d 20 5f 57 | 45 4e 65 77 4f 62 6a 65 |err = _W|ENewObje|
|00005700| 63 74 28 6f 62 6a 65 63 | 74 54 79 70 65 2c 20 6f |ct(objec|tType, o|
|00005710| 62 6a 65 63 74 44 61 74 | 61 48 61 6e 64 6c 65 2c |bjectDat|aHandle,|
|00005720| 20 68 57 45 2c 20 26 74 | 73 2e 74 73 4f 62 6a 65 | hWE, &t|s.tsObje|
|00005730| 63 74 29 29 20 21 3d 20 | 6e 6f 45 72 72 29 0d 09 |ct)) != |noErr)..|
|00005740| 7b 0d 09 09 67 6f 74 6f | 20 63 6c 65 61 6e 75 70 |{...goto| cleanup|
|00005750| 3b 0d 09 7d 0d 0d 09 2f | 2f 20 75 73 65 20 74 68 |;..}.../|/ use th|
|00005760| 65 20 73 70 65 63 69 66 | 69 65 64 20 6f 62 6a 65 |e specif|ied obje|
|00005770| 63 74 20 73 69 7a 65 2c | 20 75 6e 6c 65 73 73 20 |ct size,| unless |
|00005780| 69 74 20 69 73 20 28 30 | 2c 20 30 29 2c 20 69 6e |it is (0|, 0), in|
|00005790| 20 77 68 69 63 68 20 63 | 61 73 65 20 6b 65 65 70 | which c|ase keep|
|000057a0| 20 74 68 65 20 64 65 66 | 61 75 6c 74 20 73 69 7a | the def|ault siz|
|000057b0| 65 0d 09 69 66 20 28 2a | 20 28 53 49 6e 74 33 32 |e..if (*| (SInt32|
|000057c0| 20 2a 29 20 26 6f 62 6a | 65 63 74 53 69 7a 65 20 | *) &obj|ectSize |
|000057d0| 21 3d 20 30 29 0d 09 7b | 0d 09 09 28 2a 74 73 2e |!= 0)..{|...(*ts.|
|000057e0| 74 73 4f 62 6a 65 63 74 | 29 2d 3e 6f 62 6a 65 63 |tsObject|)->objec|
|000057f0| 74 53 69 7a 65 20 3d 20 | 6f 62 6a 65 63 74 53 69 |tSize = |objectSi|
|00005800| 7a 65 3b 0d 09 7d 0d 0d | 09 2f 2f 20 69 6e 63 72 |ze;..}..|.// incr|
|00005810| 65 6d 65 6e 74 20 6d 6f | 64 69 66 69 63 61 74 69 |ement mo|dificati|
|00005820| 6f 6e 20 63 6f 75 6e 74 | 0d 09 70 57 45 2d 3e 6d |on count|..pWE->m|
|00005830| 6f 64 43 6f 75 6e 74 2b | 2b 3b 0d 0d 09 2f 2f 20 |odCount+|+;...// |
|00005840| 69 66 20 75 6e 64 6f 20 | 73 75 70 70 6f 72 74 20 |if undo |support |
|00005850| 69 73 20 65 6e 61 62 6c | 65 64 2c 20 73 61 76 65 |is enabl|ed, save|
|00005860| 20 63 75 72 72 65 6e 74 | 20 73 65 6c 65 63 74 69 | current| selecti|
|00005870| 6f 6e 20 72 61 6e 67 65 | 0d 09 69 66 20 28 42 54 |on range|..if (BT|
|00005880| 53 54 28 70 57 45 2d 3e | 66 65 61 74 75 72 65 73 |ST(pWE->|features|
|00005890| 2c 20 77 65 46 55 6e 64 | 6f 29 29 0d 09 7b 0d 09 |, weFUnd|o))..{..|
|000058a0| 09 57 45 43 6c 65 61 72 | 55 6e 64 6f 28 68 57 45 |.WEClear|Undo(hWE|
|000058b0| 29 3b 0d 09 09 69 66 20 | 28 5f 57 45 4e 65 77 41 |);...if |(_WENewA|
|000058c0| 63 74 69 6f 6e 28 6f 66 | 66 73 65 74 2c 20 70 57 |ction(of|fset, pW|
|000058d0| 45 2d 3e 73 65 6c 45 6e | 64 2c 20 31 2c 20 77 65 |E->selEn|d, 1, we|
|000058e0| 41 4b 55 6e 73 70 65 63 | 69 66 69 65 64 2c 20 30 |AKUnspec|ified, 0|
|000058f0| 2c 20 68 57 45 2c 20 26 | 68 41 63 74 69 6f 6e 29 |, hWE, &|hAction)|
|00005900| 20 3d 3d 20 6e 6f 45 72 | 72 29 0d 09 09 7b 0d 09 | == noEr|r)...{..|
|00005910| 09 09 5f 57 45 50 75 73 | 68 41 63 74 69 6f 6e 28 |.._WEPus|hAction(|
|00005920| 68 41 63 74 69 6f 6e 29 | 3b 0d 09 09 7d 0d 09 7d |hAction)|;...}..}|
|00005930| 0d 0d 09 2f 2f 20 64 65 | 6c 65 74 65 20 63 75 72 |...// de|lete cur|
|00005940| 72 65 6e 74 20 73 65 6c | 65 63 74 69 6f 6e 0d 09 |rent sel|ection..|
|00005950| 69 66 20 28 28 65 72 72 | 20 3d 20 5f 57 45 44 65 |if ((err| = _WEDe|
|00005960| 6c 65 74 65 52 61 6e 67 | 65 28 6f 66 66 73 65 74 |leteRang|e(offset|
|00005970| 2c 20 70 57 45 2d 3e 73 | 65 6c 45 6e 64 2c 20 68 |, pWE->s|elEnd, h|
|00005980| 57 45 29 29 20 21 3d 20 | 6e 6f 45 72 72 29 0d 09 |WE)) != |noErr)..|
|00005990| 7b 0d 09 09 67 6f 74 6f | 20 63 6c 65 61 6e 75 70 |{...goto| cleanup|
|000059a0| 3b 0d 09 7d 0d 0d 09 2f | 2f 20 69 6e 73 65 72 74 |;..}.../|/ insert|
|000059b0| 20 61 20 6b 4f 62 6a 65 | 63 74 4d 61 72 6b 65 72 | a kObje|ctMarker|
|000059c0| 20 63 68 61 72 61 63 74 | 65 72 20 61 74 20 74 68 | charact|er at th|
|000059d0| 65 20 69 6e 73 65 72 74 | 69 6f 6e 20 70 6f 69 6e |e insert|ion poin|
|000059e0| 74 0d 09 69 66 20 28 28 | 65 72 72 20 3d 20 5f 57 |t..if ((|err = _W|
|000059f0| 45 49 6e 73 65 72 74 54 | 65 78 74 28 6f 66 66 73 |EInsertT|ext(offs|
|00005a00| 65 74 2c 20 26 6d 61 72 | 6b 65 72 2c 20 73 69 7a |et, &mar|ker, siz|
|00005a10| 65 6f 66 28 6d 61 72 6b | 65 72 29 2c 20 68 57 45 |eof(mark|er), hWE|
|00005a20| 29 29 20 21 3d 20 6e 6f | 45 72 72 29 0d 09 7b 0d |)) != no|Err)..{.|
|00005a30| 09 09 67 6f 74 6f 20 63 | 6c 65 61 6e 75 70 3b 0d |..goto c|leanup;.|
|00005a40| 09 7d 0d 0d 09 2f 2f 20 | 6d 6f 76 65 20 74 68 65 |.}...// |move the|
|00005a50| 20 69 6e 73 65 72 74 69 | 6f 6e 20 70 6f 69 6e 74 | inserti|on point|
|00005a60| 20 61 66 74 65 72 20 74 | 68 65 20 69 6e 73 65 72 | after t|he inser|
|00005a70| 74 65 64 20 74 65 78 74 | 0d 09 65 6e 64 4f 66 66 |ted text|..endOff|
|00005a80| 73 65 74 20 3d 20 6f 66 | 66 73 65 74 20 2b 20 31 |set = of|fset + 1|
|00005a90| 3b 0d 09 70 57 45 2d 3e | 73 65 6c 53 74 61 72 74 |;..pWE->|selStart|
|00005aa0| 20 3d 20 65 6e 64 4f 66 | 66 73 65 74 3b 0d 09 70 | = endOf|fset;..p|
|00005ab0| 57 45 2d 3e 73 65 6c 45 | 6e 64 20 3d 20 65 6e 64 |WE->selE|nd = end|
|00005ac0| 4f 66 66 73 65 74 3b 0d | 0d 09 2f 2f 20 72 65 63 |Offset;.|..// rec|
|00005ad0| 6f 72 64 20 61 20 72 65 | 66 65 72 65 6e 63 65 20 |ord a re|ference |
|00005ae0| 74 6f 20 74 68 65 20 6f | 62 6a 65 63 74 20 64 65 |to the o|bject de|
|00005af0| 73 63 72 69 70 74 6f 72 | 20 69 6e 20 74 68 65 20 |scriptor| in the |
|00005b00| 73 74 79 6c 65 20 74 61 | 62 6c 65 0d 09 65 72 72 |style ta|ble..err|
|00005b10| 20 3d 20 5f 57 45 53 65 | 74 53 74 79 6c 65 52 61 | = _WESe|tStyleRa|
|00005b20| 6e 67 65 28 6f 66 66 73 | 65 74 2c 20 65 6e 64 4f |nge(offs|et, endO|
|00005b30| 66 66 73 65 74 2c 20 77 | 65 44 6f 4f 62 6a 65 63 |ffset, w|eDoObjec|
|00005b40| 74 2c 20 26 74 73 2c 20 | 68 57 45 29 3b 0d 09 74 |t, &ts, |hWE);..t|
|00005b50| 73 2e 74 73 4f 62 6a 65 | 63 74 20 3d 20 6e 69 6c |s.tsObje|ct = nil|
|00005b60| 3b 0d 09 69 66 20 28 65 | 72 72 20 21 3d 20 6e 6f |;..if (e|rr != no|
|00005b70| 45 72 72 29 0d 09 7b 0d | 09 09 67 6f 74 6f 20 63 |Err)..{.|..goto c|
|00005b80| 6c 65 61 6e 75 70 3b 0d | 09 7d 0d 0d 09 2f 2f 20 |leanup;.|.}...// |
|00005b90| 69 6e 76 61 6c 69 64 20 | 74 68 65 20 6e 75 6c 6c |invalid |the null|
|00005ba0| 20 73 74 79 6c 65 0d 09 | 42 43 4c 52 28 70 57 45 | style..|BCLR(pWE|
|00005bb0| 2d 3e 66 6c 61 67 73 2c | 20 77 65 46 55 73 65 4e |->flags,| weFUseN|
|00005bc0| 75 6c 6c 53 74 79 6c 65 | 29 3b 0d 0d 09 2f 2f 20 |ullStyle|);...// |
|00005bd0| 72 65 64 72 61 77 20 74 | 68 65 20 74 65 78 74 0d |redraw t|he text.|
|00005be0| 09 69 66 20 28 28 65 72 | 72 20 3d 20 5f 57 45 52 |.if ((er|r = _WER|
|00005bf0| 65 64 72 61 77 28 6f 66 | 66 73 65 74 2c 20 65 6e |edraw(of|fset, en|
|00005c00| 64 4f 66 66 73 65 74 2c | 20 68 57 45 29 29 20 21 |dOffset,| hWE)) !|
|00005c10| 3d 20 6e 6f 45 72 72 29 | 0d 09 7b 0d 09 09 67 6f |= noErr)|..{...go|
|00005c20| 74 6f 20 63 6c 65 61 6e | 75 70 3b 0d 09 7d 0d 0d |to clean|up;..}..|
|00005c30| 09 2f 2f 20 63 6c 65 61 | 72 20 72 65 73 75 6c 74 |.// clea|r result|
|00005c40| 20 63 6f 64 65 0d 09 65 | 72 72 20 3d 20 6e 6f 45 | code..e|rr = noE|
|00005c50| 72 72 3b 0d 0d 63 6c 65 | 61 6e 75 70 3a 0d 09 2f |rr;..cle|anup:../|
|00005c60| 2f 20 63 6c 65 61 6e 20 | 75 70 0d 09 5f 57 45 46 |/ clean |up.._WEF|
|00005c70| 6f 72 67 65 74 48 61 6e | 64 6c 65 28 28 48 61 6e |orgetHan|dle((Han|
|00005c80| 64 6c 65 20 2a 29 20 26 | 74 73 2e 74 73 4f 62 6a |dle *) &|ts.tsObj|
|00005c90| 65 63 74 29 3b 0d 0d 09 | 2f 2f 20 75 6e 6c 6f 63 |ect);...|// unloc|
|00005ca0| 6b 20 74 68 65 20 57 45 | 20 72 65 63 6f 72 64 0d |k the WE| record.|
|00005cb0| 09 5f 57 45 53 65 74 48 | 61 6e 64 6c 65 4c 6f 63 |._WESetH|andleLoc|
|00005cc0| 6b 28 28 48 61 6e 64 6c | 65 29 20 68 57 45 2c 20 |k((Handl|e) hWE, |
|00005cd0| 73 61 76 65 57 45 4c 6f | 63 6b 29 3b 0d 0d 09 2f |saveWELo|ck);.../|
|00005ce0| 2f 20 72 65 74 75 72 6e | 20 72 65 73 75 6c 74 20 |/ return| result |
|00005cf0| 63 6f 64 65 0d 09 72 65 | 74 75 72 6e 20 65 72 72 |code..re|turn err|
|00005d00| 3b 0d 7d 0d 0d 23 65 6e | 64 69 66 0d 0d 70 61 73 |;.}..#en|dif..pas|
|00005d10| 63 61 6c 20 4f 53 45 72 | 72 20 57 45 44 65 6c 65 |cal OSEr|r WEDele|
|00005d20| 74 65 28 57 45 48 61 6e | 64 6c 65 20 68 57 45 29 |te(WEHan|dle hWE)|
|00005d30| 0d 7b 0d 09 57 45 50 74 | 72 20 70 57 45 3b 0d 09 |.{..WEPt|r pWE;..|
|00005d40| 57 45 41 63 74 69 6f 6e | 48 61 6e 64 6c 65 20 68 |WEAction|Handle h|
|00005d50| 41 63 74 69 6f 6e 3b 0d | 09 53 49 6e 74 33 32 20 |Action;.|.SInt32 |
|00005d60| 72 61 6e 67 65 53 74 61 | 72 74 2c 20 72 61 6e 67 |rangeSta|rt, rang|
|00005d70| 65 45 6e 64 3b 0d 09 42 | 6f 6f 6c 65 61 6e 20 73 |eEnd;..B|oolean s|
|00005d80| 61 76 65 57 45 4c 6f 63 | 6b 3b 0d 09 4f 53 45 72 |aveWELoc|k;..OSEr|
|00005d90| 72 20 65 72 72 3b 0d 0d | 09 2f 2f 20 6c 6f 63 6b |r err;..|.// lock|
|00005da0| 20 74 68 65 20 57 45 20 | 72 65 63 6f 72 64 0d 09 | the WE |record..|
|00005db0| 73 61 76 65 57 45 4c 6f | 63 6b 20 3d 20 5f 57 45 |saveWELo|ck = _WE|
|00005dc0| 53 65 74 48 61 6e 64 6c | 65 4c 6f 63 6b 28 28 48 |SetHandl|eLock((H|
|00005dd0| 61 6e 64 6c 65 29 20 68 | 57 45 2c 20 74 72 75 65 |andle) h|WE, true|
|00005de0| 29 3b 0d 09 70 57 45 20 | 3d 20 2a 68 57 45 3b 0d |);..pWE |= *hWE;.|
|00005df0| 0d 09 2f 2f 20 72 65 74 | 75 72 6e 20 61 6e 20 65 |..// ret|urn an e|
|00005e00| 72 72 6f 72 20 63 6f 64 | 65 20 69 66 20 74 68 69 |rror cod|e if thi|
|00005e10| 73 20 69 6e 73 74 61 6e | 63 65 20 69 73 20 72 65 |s instan|ce is re|
|00005e20| 61 64 2d 6f 6e 6c 79 0d | 09 65 72 72 20 3d 20 77 |ad-only.|.err = w|
|00005e30| 65 52 65 61 64 4f 6e 6c | 79 45 72 72 3b 0d 09 69 |eReadOnl|yErr;..i|
|00005e40| 66 20 28 42 54 53 54 28 | 70 57 45 2d 3e 66 65 61 |f (BTST(|pWE->fea|
|00005e50| 74 75 72 65 73 2c 20 77 | 65 46 52 65 61 64 4f 6e |tures, w|eFReadOn|
|00005e60| 6c 79 29 29 0d 09 7b 0d | 09 09 67 6f 74 6f 20 63 |ly))..{.|..goto c|
|00005e70| 6c 65 61 6e 75 70 3b 0d | 09 7d 0d 0d 09 2f 2f 20 |leanup;.|.}...// |
|00005e80| 73 74 6f 70 20 61 6e 79 | 20 6f 6e 67 6f 69 6e 67 |stop any| ongoing|
|00005e90| 20 69 6e 6c 69 6e 65 20 | 69 6e 70 75 74 20 73 65 | inline |input se|
|00005ea0| 73 73 69 6f 6e 0d 09 57 | 45 53 74 6f 70 49 6e 6c |ssion..W|EStopInl|
|00005eb0| 69 6e 65 53 65 73 73 69 | 6f 6e 28 68 57 45 29 3b |ineSessi|on(hWE);|
|00005ec0| 0d 0d 09 2f 2f 20 67 65 | 74 20 63 75 72 72 65 6e |...// ge|t curren|
|00005ed0| 74 20 73 65 6c 65 63 74 | 69 6f 6e 20 72 61 6e 67 |t select|ion rang|
|00005ee0| 65 0d 09 72 61 6e 67 65 | 53 74 61 72 74 20 3d 20 |e..range|Start = |
|00005ef0| 70 57 45 2d 3e 73 65 6c | 53 74 61 72 74 3b 0d 09 |pWE->sel|Start;..|
|00005f00| 72 61 6e 67 65 45 6e 64 | 20 3d 20 70 57 45 2d 3e |rangeEnd| = pWE->|
|00005f10| 73 65 6c 45 6e 64 3b 0d | 0d 09 2f 2f 20 64 6f 20 |selEnd;.|..// do |
|00005f20| 6e 6f 74 68 69 6e 67 20 | 69 66 20 74 68 65 20 73 |nothing |if the s|
|00005f30| 65 6c 65 63 74 69 6f 6e | 20 72 61 6e 67 65 20 69 |election| range i|
|00005f40| 73 20 65 6d 70 74 79 0d | 09 69 66 20 28 72 61 6e |s empty.|.if (ran|
|00005f50| 67 65 53 74 61 72 74 20 | 3c 20 72 61 6e 67 65 45 |geStart |< rangeE|
|00005f60| 6e 64 29 0d 09 7b 0d 0d | 09 09 2f 2f 20 69 6e 63 |nd)..{..|..// inc|
|00005f70| 72 65 6d 65 6e 74 20 6d | 6f 64 69 66 69 63 61 74 |rement m|odificat|
|00005f80| 69 6f 6e 20 63 6f 75 6e | 74 0d 09 09 70 57 45 2d |ion coun|t...pWE-|
|00005f90| 3e 6d 6f 64 43 6f 75 6e | 74 2b 2b 3b 0d 0d 09 09 |>modCoun|t++;....|
|00005fa0| 2f 2f 20 72 61 6e 67 65 | 20 65 78 74 65 6e 73 69 |// range| extensi|
|00005fb0| 6f 6e 20 66 6f 72 20 69 | 6e 74 65 6c 6c 69 67 65 |on for i|ntellige|
|00005fc0| 6e 74 20 63 75 74 2d 61 | 6e 64 2d 70 61 73 74 65 |nt cut-a|nd-paste|
|00005fd0| 0d 09 09 5f 57 45 49 6e | 74 65 6c 6c 69 67 65 6e |..._WEIn|telligen|
|00005fe0| 74 43 75 74 28 26 72 61 | 6e 67 65 53 74 61 72 74 |tCut(&ra|ngeStart|
|00005ff0| 2c 20 26 72 61 6e 67 65 | 45 6e 64 2c 20 68 57 45 |, &range|End, hWE|
|00006000| 29 3b 0d 0d 09 09 2f 2f | 20 69 66 20 75 6e 64 6f |);....//| if undo|
|00006010| 20 73 75 70 70 6f 72 74 | 20 69 73 20 65 6e 61 62 | support| is enab|
|00006020| 6c 65 64 2c 20 73 61 76 | 65 20 74 68 65 20 72 61 |led, sav|e the ra|
|00006030| 6e 67 65 20 74 6f 20 62 | 65 20 64 65 6c 65 74 65 |nge to b|e delete|
|00006040| 64 0d 09 09 69 66 20 28 | 42 54 53 54 28 70 57 45 |d...if (|BTST(pWE|
|00006050| 2d 3e 66 65 61 74 75 72 | 65 73 2c 20 77 65 46 55 |->featur|es, weFU|
|00006060| 6e 64 6f 29 29 0d 09 09 | 7b 0d 09 09 09 57 45 43 |ndo))...|{....WEC|
|00006070| 6c 65 61 72 55 6e 64 6f | 28 68 57 45 29 3b 0d 09 |learUndo|(hWE);..|
|00006080| 09 09 69 66 20 28 5f 57 | 45 4e 65 77 41 63 74 69 |..if (_W|ENewActi|
|00006090| 6f 6e 28 72 61 6e 67 65 | 53 74 61 72 74 2c 20 72 |on(range|Start, r|
|000060a0| 61 6e 67 65 45 6e 64 2c | 20 30 2c 20 77 65 41 4b |angeEnd,| 0, weAK|
|000060b0| 43 6c 65 61 72 2c 20 30 | 2c 20 68 57 45 2c 20 26 |Clear, 0|, hWE, &|
|000060c0| 68 41 63 74 69 6f 6e 29 | 20 3d 3d 20 6e 6f 45 72 |hAction)| == noEr|
|000060d0| 72 29 0d 09 09 09 7b 0d | 09 09 09 09 5f 57 45 50 |r)....{.|...._WEP|
|000060e0| 75 73 68 41 63 74 69 6f | 6e 28 68 41 63 74 69 6f |ushActio|n(hActio|
|000060f0| 6e 29 3b 0d 09 09 09 7d | 0d 09 09 7d 0d 0d 09 09 |n);....}|...}....|
|00006100| 2f 2f 20 64 65 6c 65 74 | 65 20 74 68 65 20 73 65 |// delet|e the se|
|00006110| 6c 65 63 74 69 6f 6e 20 | 72 61 6e 67 65 0d 09 09 |lection |range...|
|00006120| 69 66 20 28 28 65 72 72 | 20 3d 20 5f 57 45 44 65 |if ((err| = _WEDe|
|00006130| 6c 65 74 65 52 61 6e 67 | 65 28 72 61 6e 67 65 53 |leteRang|e(rangeS|
|00006140| 74 61 72 74 2c 20 72 61 | 6e 67 65 45 6e 64 2c 20 |tart, ra|ngeEnd, |
|00006150| 68 57 45 29 29 20 21 3d | 20 6e 6f 45 72 72 29 0d |hWE)) !=| noErr).|
|00006160| 09 09 7b 0d 09 09 09 67 | 6f 74 6f 20 63 6c 65 61 |..{....g|oto clea|
|00006170| 6e 75 70 3b 0d 09 09 7d | 0d 0d 09 09 2f 2f 20 72 |nup;...}|....// r|
|00006180| 65 73 65 74 20 74 68 65 | 20 73 65 6c 65 63 74 69 |eset the| selecti|
|00006190| 6f 6e 20 72 61 6e 67 65 | 0d 09 09 70 57 45 2d 3e |on range|...pWE->|
|000061a0| 73 65 6c 53 74 61 72 74 | 20 3d 20 72 61 6e 67 65 |selStart| = range|
|000061b0| 53 74 61 72 74 3b 0d 09 | 09 70 57 45 2d 3e 73 65 |Start;..|.pWE->se|
|000061c0| 6c 45 6e 64 20 3d 20 72 | 61 6e 67 65 53 74 61 72 |lEnd = r|angeStar|
|000061d0| 74 3b 0d 0d 09 09 2f 2f | 20 72 65 64 72 61 77 20 |t;....//| redraw |
|000061e0| 74 68 65 20 74 65 78 74 | 0d 09 09 69 66 20 28 28 |the text|...if ((|
|000061f0| 65 72 72 20 3d 20 5f 57 | 45 52 65 64 72 61 77 28 |err = _W|ERedraw(|
|00006200| 72 61 6e 67 65 53 74 61 | 72 74 2c 20 72 61 6e 67 |rangeSta|rt, rang|
|00006210| 65 53 74 61 72 74 2c 20 | 68 57 45 29 29 20 21 3d |eStart, |hWE)) !=|
|00006220| 20 6e 6f 45 72 72 29 0d | 09 09 7b 0d 09 09 09 67 | noErr).|..{....g|
|00006230| 6f 74 6f 20 63 6c 65 61 | 6e 75 70 3b 0d 09 09 7d |oto clea|nup;...}|
|00006240| 0d 09 7d 20 2f 2f 20 69 | 66 20 6e 6f 6e 2d 65 6d |..} // i|f non-em|
|00006250| 70 74 79 20 73 65 6c 65 | 63 74 69 6f 6e 0d 0d 09 |pty sele|ction...|
|00006260| 2f 2f 20 63 6c 65 61 72 | 20 72 65 73 75 6c 74 20 |// clear| result |
|00006270| 63 6f 64 65 0d 09 65 72 | 72 20 3d 20 6e 6f 45 72 |code..er|r = noEr|
|00006280| 72 3b 0d 0d 63 6c 65 61 | 6e 75 70 3a 0d 09 2f 2f |r;..clea|nup:..//|
|00006290| 20 75 6e 6c 6f 63 6b 20 | 74 68 65 20 57 45 20 72 | unlock |the WE r|
|000062a0| 65 63 6f 72 64 0d 09 5f | 57 45 53 65 74 48 61 6e |ecord.._|WESetHan|
|000062b0| 64 6c 65 4c 6f 63 6b 28 | 28 48 61 6e 64 6c 65 29 |dleLock(|(Handle)|
|000062c0| 20 68 57 45 2c 20 73 61 | 76 65 57 45 4c 6f 63 6b | hWE, sa|veWELock|
|000062d0| 29 3b 0d 0d 09 2f 2f 20 | 72 65 74 75 72 6e 20 72 |);...// |return r|
|000062e0| 65 73 75 6c 74 20 63 6f | 64 65 0d 09 72 65 74 75 |esult co|de..retu|
|000062f0| 72 6e 20 65 72 72 3b 0d | 7d 0d 0d 70 61 73 63 61 |rn err;.|}..pasca|
|00006300| 6c 20 4f 53 45 72 72 20 | 57 45 43 75 74 28 57 45 |l OSErr |WECut(WE|
|00006310| 48 61 6e 64 6c 65 20 68 | 57 45 29 0d 7b 0d 09 4f |Handle h|WE).{..O|
|00006320| 53 45 72 72 20 65 72 72 | 3b 0d 0d 09 2f 2f 20 66 |SErr err|;...// f|
|00006330| 69 72 73 74 20 63 6f 70 | 79 2e 2e 2e 0d 09 69 66 |irst cop|y.....if|
|00006340| 20 28 28 65 72 72 20 3d | 20 57 45 43 6f 70 79 28 | ((err =| WECopy(|
|00006350| 68 57 45 29 29 20 21 3d | 20 6e 6f 45 72 72 29 0d |hWE)) !=| noErr).|
|00006360| 09 7b 0d 09 09 67 6f 74 | 6f 20 63 6c 65 61 6e 75 |.{...got|o cleanu|
|00006370| 70 3b 0d 09 7d 0d 0d 09 | 2f 2f 20 2e 2e 2e 20 74 |p;..}...|// ... t|
|00006380| 68 65 6e 20 64 65 6c 65 | 74 65 0d 09 69 66 20 28 |hen dele|te..if (|
|00006390| 28 65 72 72 20 3d 20 57 | 45 44 65 6c 65 74 65 28 |(err = W|EDelete(|
|000063a0| 68 57 45 29 29 20 21 3d | 20 6e 6f 45 72 72 29 0d |hWE)) !=| noErr).|
|000063b0| 09 7b 0d 09 09 67 6f 74 | 6f 20 63 6c 65 61 6e 75 |.{...got|o cleanu|
|000063c0| 70 3b 0d 09 7d 0d 0d 09 | 2f 2f 20 63 68 61 6e 67 |p;..}...|// chang|
|000063d0| 65 20 74 68 65 20 61 63 | 74 69 6f 6e 20 6b 69 6e |e the ac|tion kin|
|000063e0| 64 20 6f 66 20 74 68 65 | 20 6d 6f 73 74 20 72 65 |d of the| most re|
|000063f0| 63 65 6e 74 20 61 63 74 | 69 6f 6e 2c 20 69 66 20 |cent act|ion, if |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.